From b09253bc21951ffb606633115a406312f99f50d3 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Mon, 18 Dec 2023 16:16:29 +0800 Subject: [PATCH 001/139] opt MUL/DIV lowering logic --- src/mono/mono/mini/mini-riscv.c | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 4ef94ee41cd21..33d5be8eb6b70 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2948,45 +2948,29 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) break; } case OP_MUL_IMM: - case OP_IMUL_IMM: - case OP_LMUL_IMM: - case OP_IDIV_IMM: { g_assert (riscv_stdext_m); NEW_INS_BEFORE (cfg, ins, temp, OP_ICONST); temp->inst_c0 = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); ins->sreg2 = temp->dreg; ins->inst_imm = 0; - switch (ins->opcode) { - case OP_MUL_IMM: #ifdef TARGET_RISCV64 ins->opcode = OP_LMUL; #else ins->opcode = OP_IMUL; #endif - break; - case OP_IMUL_IMM: - ins->opcode = OP_IMUL; - break; - case OP_LMUL_IMM: - ins->opcode = OP_LMUL; - break; - case OP_DIV_IMM: + break; + case OP_DIV_IMM: + mono_decompose_op_imm (cfg, bb, ins); #ifdef TARGET_RISCV64 - ins->opcode = OP_LDIV; + g_assert(ins->opcode == OP_LDIV); #else - ins->opcode = OP_IDIV; + g_assert(ins->opcode == OP_IDIV); #endif - break; - case OP_IDIV_IMM: - ins->opcode = OP_IDIV; - break; - case OP_LDIV_IMM: - ins->opcode = OP_LDIV; - break; - } break; - } + case OP_IMUL_IMM: + case OP_LMUL_IMM: + case OP_IDIV_IMM: case OP_IREM_IMM: case OP_LREM_IMM: case OP_IREM_UN_IMM: From bb7852dd3d52c698e08462c102caa0c1e4845202 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Mon, 18 Dec 2023 16:18:10 +0800 Subject: [PATCH 002/139] update --- 2024.01.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 2024.01.md diff --git a/2024.01.md b/2024.01.md new file mode 100644 index 0000000000000..7af8b9748c59f --- /dev/null +++ b/2024.01.md @@ -0,0 +1,39 @@ +# 2024年预期产出 + +> 本周期内预计持续完善Mono的RISC-V 支持。尝试打包 RISC-V 的 runtime安装包 ,并且尝试帮助/推进runtime 建立对于在 RISC-V 上Native构建Mono的的二进制文件支持。 + +## 实现Mono的RISC-V支持 + - 目标:实现 Mono RISC-V 的稳定运行并通过相关的回归测试。具体时长可能会随着验证进度被缩短/增加 + + - 交付: + 1. 向上游(dotnet/runtime)提交Mono后端RISC-V支持的PR + 2. 测试运行结果,失败项目的失败原因。 + + - 验收指标: PR被接收,CI通过 + - 周期:2-3 个月 + +## 尝试打包 RISC-V 的runtime安装包 + > 预期可能需要使用微软/dotnet提供一些闭源的二进制工具集? 因此可能需要上游的指导。 + - 目标:尝试编译并且打包以Mono RISC-V为后端的dotnet安装包。 + + - 交付: + 1. 一个类似`dotnet-sdk--linux-riscv64.tar.gz`的压缩包,其中应包括dotnet程序以及相关运行库,.Net Runtime library,.Net SDKs 以及安装脚本等。 + 2. 与上游沟通并将安装包发布在`https://dotnetcli.azureedge.net/dotnet/Sdk/` + + - 验收指标: dotnet可以直接被`dotnet-install.sh`解压并安装在RISC-V设备或qemu-system中 + - 周期:1-2个月 + +## 实现RISC-V上Native构建dotnet/runtime + - 先决条件: 拥有一个可以在RISC-V设备/qemu-system中独立安装的安装包。Mono RISC-V可以正确运行roslyn。 + + - 目标:在RISC-V设备或qemu-system中构建并打包dotnet安装包。 + + - 交付:向上游(dotnet/runtime)提交PR修复运行roslyn时Mono RISC-V出现的Bug + - 验收指标:可以在`qemu-system-riscv64`编译打包dotnet安装包。 + - 周期:1-2个月 + +## 在RISC-V运行图形程序 + - 目标:尝试在RISC-V开发板/qemu-system上使用Mono运行图形程序,例如星露谷物语。 + - 交付:向上游(dotnet/runtime)提交PR修复运行图形程序时Mono RISC-V出现的Bug + - 验收指标:可以在`qemu-system-riscv64`运行图形程序如游戏星露谷物语 + - 周期:2-3个月 From 2196aeda16874971b7232b38a5cb9d0a26d00042 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Mon, 18 Dec 2023 16:18:29 +0800 Subject: [PATCH 003/139] update --- src/mono/sample/TestRun/Makefile | 471 +++++++++++++++++++++++++++++++ src/tests/run.sh | 2 +- 2 files changed, 472 insertions(+), 1 deletion(-) create mode 100644 src/mono/sample/TestRun/Makefile diff --git a/src/mono/sample/TestRun/Makefile b/src/mono/sample/TestRun/Makefile new file mode 100644 index 0000000000000..00ce02d47c40a --- /dev/null +++ b/src/mono/sample/TestRun/Makefile @@ -0,0 +1,471 @@ +TOP=../../../../ +DOTNET:=$(TOP)dotnet.sh +DOTNET_Q_ARGS=--nologo -v:q -consoleloggerparameters:NoSummary + +MONO_CONFIG?=Debug +MONO_ARCH=riscv64 +TARGET_OS=linux +AOT?=false +QEMU=qemu-riscv64-static +SAMPLE_PATH=/home/wuxinlong/workspace/samples/csharp/getting-started/console-webapiclient +ANY_PATH= /home/wuxinlong/workspace/samples/orleans/HelloWorld/bin/Debug/net8.0/HelloWorld.dll + +GitHubKey=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 + +#NET_TRACE_PATH= +#PGO_BINARY_PATH= +#MIBC_PROFILE_PATH= + +MONO_ENV_DEBUG_OPTIONS = "-v" +MONO_ENV_RUN_OPTIONS = "--trace=all" + +build: TestRun.cs + @mcs TestRun.cs + +run-baseline: build + COMPlus_DebugWriteToStdErr=1 \ + MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ + $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-x64/dotnet TestRun.exe + +run-any-baseline: + COMPlus_DebugWriteToStdErr=1 \ + MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ + $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-x64/dotnet \ + $(ANY_PATH) + +run: build + @COMPlus_DebugWriteToStdErr=1 \ + MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet TestRun.exe + +run-any: + COMPlus_DebugWriteToStdErr=1 \ + MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(ANY_PATH) + +run-webapiclient-baseline: + COMPlus_DebugWriteToStdErr=1 \ + MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ + $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-x64/dotnet \ + $(SAMPLE_PATH)/bin/Debug/net8.0/webapiclient.dll + +run-webapiclient: + COMPlus_DebugWriteToStdErr=1 \ + MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ + $(QEMU) -L $(TOP).tools/rootfs/riscv64/ \ + $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/dotnet \ + $(SAMPLE_PATH)/bin/Debug/net8.0/webapiclient.dll + +debug: build + COMPlus_DebugWriteToStdErr=1 \ + MONO_LOG_LEVEL=debug MONO_LOG_MASK=all \ + MONO_ENV_OPTIONS=$(MONO_ENV_DEBUG_OPTIONS) \ + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ \ + -g 12345 \ + $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet TestRun.exe &\ + gdb-multiarch -ex 'target remote localhost:12345' \ + -ex "set sysroot $(TOP).tools/rootfs/riscv64" -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/shared/Microsoft.NETCore.App/8.0.0" \ + -ex "b mini.c:2156" \ + $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet + +debug-webapiclient: + COMPlus_DebugWriteToStdErr=1 \ + MONO_ENV_OPTIONS=$(MONO_ENV_DEBUG_OPTIONS) \ + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ \ + -g 12345 \ + $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(SAMPLE_PATH)/bin/Debug/net8.0/webapiclient.dll &\ + gdb-multiarch -ex 'target remote localhost:12345' \ + -ex "set sysroot $(TOP).tools/rootfs/riscv64" \ + -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/shared/Microsoft.NETCore.App/8.0.0" \ + -ex "b mini.c:2156" \ + $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet + +debug-any: + COMPlus_DebugWriteToStdErr=1 \ + MONO_ENV_OPTIONS=$(MONO_ENV_DEBUG_OPTIONS) \ + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ \ + -g 12345 \ + $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(ANY_PATH) &\ + gdb-multiarch -ex 'target remote localhost:12345' \ + -iex "add-auto-load-safe-path /home/wuxinlong/workspace/runtime/src/mono/sample/TestRun/" \ + -ex "set sysroot $(TOP).tools/rootfs/riscv64" \ + -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/shared/Microsoft.NETCore.App/8.0.0" \ + -ex "b mini.c:2156" \ + -ex "handle SIG35 print nostop ignore" \ + $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet + +remote_gdb: + gdb-multiarch -ex 'target remote localhost:12345' \ + -iex "add-auto-load-safe-path /home/wuxinlong/workspace/runtime/src/mono/sample/TestRun/" \ + -ex "set sysroot $(TOP).tools/rootfs/riscv64" \ + -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/shared/Microsoft.NETCore.App/8.0.0" \ + -ex "b mono_break" \ + -ex "handle SIG35 print nostop ignore" \ + $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet + +debug-any-baseline: + COMPlus_DebugWriteToStdErr=1 \ + MONO_ENV_OPTIONS=$(MONO_ENV_DEBUG_OPTIONS) \ + gdb \ + -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-x86/shared/Microsoft.NETCore.App/8.0.0" \ + -ex "b mini.c:2156" \ + --args $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-x64/dotnet \ + $(ANY_PATH) \ + +clean: + rm -f *.exe *.exe.mdb +# 0x4015437b1a + +# System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetException +# 1248 +0xd4 +# System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException +# +0x118 + +# System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Create +# 311 + +# TeleprompterConsole.Program/d__2:MoveNext () +# 322 +0xec + +# TeleprompterConsole.Program:ShowTeleprompter +# 319 +0xcc + + +# Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxListBuilder:ToListNode +# 829 +# c 87 +# 0x4002c1abf8 + +# Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken:Create +# 831 +# +0x848 +# c 5 + +# Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken/SyntaxTokenWithTrivia:.ctor +# 0xe8 +# Microsoft.CodeAnalysis.GreenNode:AdjustFlagsAndWidth +# 0xd4 + +# COMPlus_DebugWriteToStdErr="1" MONO_LOG_LEVEL="debug" MONO_LOG_MASK="all" COREHOST_TRACE="1" COREHOST_TRACE_VERBOSITY="4" MONO_ENV_OPTIONS="--compile-all --trace=all" qemu-riscv64 -L ../../../..//.tools/rootfs/riscv64/ -g 12345 ../../../../artifacts/bin/testhost/net8.0-Linux-Debug-riscv64/dotnet TestRun.exe + +# ROOTFS_DIR="" ./build.sh mono+libs+host -c Debug +# ./build.sh mono+libs+host -c Debug --cross --arch riscv64 --build + +# ROOTFS_DIR="" ./build.sh clr.hosts -c Debug + +# ROOTFS_DIR="" ./build.sh mono+libs+host -c Debug --ninja /p:KeepNativeSymbols=true +# ./build.sh mono+libs+host -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build + +# ./build.sh -mono -debug riscv64 -ninja /p:KeepNativeSymbols=true +# ./build.sh clr.hosts --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true + +TEST_PATH=/home/wuxinlong/workspace/samples/ + +customer-relationship: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/tutorials/default-interface-members-versions/finished/customer-relationship/bin/Debug/net8.0/customer-relationship.dll + +exploration: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/tutorials/exploration/csharp6-finished/bin/Debug/net8.0/csharp6-finished.dll + +toll-calculator: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/tutorials/patterns/finished/toll-calculator/bin/Debug/net8.0/toll-calculator.dll + +mixins-with-interfaces: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/tutorials/mixins-with-interfaces/bin/Debug/net8.0/mixins-with-interfaces.dll + +datetime-parse: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/api/datetime.parse/bin/Debug/net8.0/datetime.parse.dll + +delegates-and-events: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/delegates-and-events/bin/Debug/net8.0/delegates-and-events.dll + +branches-quickstart: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/branches-quickstart/bin/Debug/net8.0/BranchesAndLoops.dll + +events: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/events/bin/Debug/net8.0/events.dll + +expression-trees: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/expression-trees/bin/Debug/net8.0/expression-trees.dll + +indexers: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/indexers/bin/Debug/net8.0/indexers.dll + +iterators: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/iterators/bin/Debug/net8.0/iterators.dll + +list-quickstart: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/list-quickstart/bin/Debug/net8.0/list-quickstart.dll + +NullableIntroduction: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/NullableIntroduction/NullableIntroduction/bin/Debug/net8.0/NullableIntroduction.dll + +numbers-quickstart: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/numbers-quickstart/bin/Debug/net8.0/NumbersInCSharp.dll + +PatternMatching: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/PatternMatching/bin/Debug/net8.0/PatternMatching.dll + +ref-tutorial: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/ref-tutorial/IntruderAlert-finished/bin/Debug/net8.0/IntruderAlert.dll + +versioning-new: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/versioning/new/bin/Debug/net8.0/new.dll + +versioning-override: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/versioning/override/bin/Debug/net8.0/override.dll + +fibonacci-msbuild: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/console-apps/fibonacci-msbuild/bin/Debug/net8.0/Hello.dll + +FibonacciBetterMsBuild: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/console-apps/FibonacciBetterMsBuild/bin/Debug/net8.0/Fibonacci.dll + +serialization: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/serialization/bin/Debug/net8.0/serialization.dll + +string_format: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/api/string.format/bin/Debug/net8.0/string.format.examples.dll + +classes-quickstart: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/classes-quickstart/bin/Debug/net8.0/classes.dll + +console-linq: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/getting-started/console-linq/bin/Debug/net8.0/console-linq.dll + +console-teleprompter: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/getting-started/console-teleprompter/bin/Debug/net8.0/console-teleprompter.dll + +console-webapiclient: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)csharp/getting-started/console-webapiclient/bin/Debug/net8.0/webapiclient.dll + +MetadataLoadContext: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/assembly/MetadataLoadContext/bin/Debug/net8.0/MetadataLoadContextSample.dll + +HelloMsBuild: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/console-apps/HelloMsBuild/bin/Debug/net8.0/Hello.dll + +DllMapDemo: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/extensions/DllMapDemo/bin/Debug/net8.0/Demo.dll + +AppWithPlugin: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/extensions/AppWithPlugin/AppWithPlugin/bin/Debug/net8.0/AppWithPlugin.dll + +AssemblyLoading: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/extensions/AssemblyLoading/AssemblyLoading/bin/Debug/net8.0/AssemblyLoading.dll + +cyrillic-to-latin: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/encoding/cyrillic-to-latin/cs/bin/Debug/net8.0/CyrillicToLatin.dll + +linker: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linker/TrimmedWithAdditionalRoots/bin/Debug/net8.0/TrimmedWithAdditionalRoots.dll + +linq/aggregate: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/aggregate/bin/Debug/net8.0/aggregate.dll + +linq/concatenation: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/concatenation/bin/Debug/net8.0/concatenation.dll + +linq/conversion: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/conversion/bin/Debug/net8.0/conversion.dll + +linq/customsequence: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/customsequence/bin/Debug/net8.0/customsequence.dll + +linq/element: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/element/bin/Debug/net8.0/element.dll + +linq/equality: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/equality/bin/Debug/net8.0/equality.dll + +linq/generation: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/generation/bin/Debug/net8.0/generation.dll + +linq/grouping: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/grouping/bin/Debug/net8.0/grouping.dll + +linq/join: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/join/bin/Debug/net8.0/join.dll + +linq/ordering: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/ordering/bin/Debug/net8.0/ordering.dll + +linq/partitioning: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/partitioning/bin/Debug/net8.0/partitioning.dll + +linq/quantifier: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/quantifier/bin/Debug/net8.0/quantifier.dll + +linq/queryexecution: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/queryexecution/bin/Debug/net8.0/queryexecution.dll + +linq/restriction: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/restriction/bin/Debug/net8.0/restriction.dll + +linq/setoperators: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/linq/csharp/setoperators/bin/Debug/net8.0/setoperators.dll + +logging/console-formatter-custom: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/logging/console-formatter-custom/bin/Debug/net8.0/console-formatter-custom.dll + +logging/console-formatter-custom-with-config: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/logging/console-formatter-custom-with-config/bin/Debug/net8.0/console-formatter-custom-with-config.dll + +logging/console-formatter-simple: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/logging/console-formatter-simple/bin/Debug/net8.0/console-formatter-simple.dll + +logging/console-formatter-systemd: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/logging/console-formatter-systemd/bin/Debug/net8.0/console-formatter-systemd.dll + +logging/logger-message-generator: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/logging/logger-message-generator/bin/Debug/net8.0/logger-message-generator.dll + +logging/worker-service-options: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/logging/worker-service-options/bin/Debug/net8.0/worker-service-options.dll + +whats-new: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/whats-new/whats-new-in-21/cs/bin/Debug/net8.0/whats-new.dll + +workers/background-service: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/workers/background-service/bin/Debug/net8.0/App.WorkerService.dll + +workers/cloud-service: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/workers/cloud-service/bin/Debug/net8.0/App.CloudService.dll + +workers/queue-service: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/workers/queue-service/bin/Debug/net8.0/App.QueueService.dll + +workers/scoped-service: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)core/workers/scoped-service/bin/Debug/net8.0/App.ScopedService.dll + +workers/timer-service: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/core/workers/timer-service/bin/Debug/net8.0/App.TimerHostedService.dll + +parallel/ComputePi: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/parallel/ComputePi/bin/Debug/net8.0/ComputePi.dll + +parallel/EditDistance: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/parallel/EditDistance/bin/Debug/net8.0/EditDistance.dll + +parallel/PLINQ: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/parallel/PLINQ/bin/Debug/net8.0/PLINQ.dll + +safe-efficient-code/ref-readonly-struct: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/safe-efficient-code/ref-readonly-struct/bin/Debug/net8.0/ref-readonly-struct.dll + +unit-testing/XUnit.TestProject: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/unit-testing/XUnit.TestProject/bin/Debug/net8.0/XUnit.Project.dll + +unit-testing/NUnit.TestProject: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/unit-testing/NUnit.TestProject/bin/Debug/net8.0/NUnit.Project.dll + +unit-testing/MSTest.Project: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/unit-testing/MSTest.Project/bin/Debug/net8.0/MSTest.Project.dll + +unit-testing-code-coverage: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/unit-testing-code-coverage/XUnit.Coverlet.Collector/bin/Debug/net8.0/XUnit.Coverlet.Collector.dll + +roslyn-sdk/Tutorials: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/roslyn-sdk/Tutorials/MakeConstTestProject/MakeConstTestProject/bin/Debug/net8.0/MakeConstTestProject.dll + +roslyn-sdk/HelloSyntaxTree: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/roslyn-sdk/SyntaxQuickStart/HelloSyntaxTree/bin/Debug/net8.0/HelloSyntaxTree.dll + +roslyn-sdk/SyntaxWalker: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/roslyn-sdk/SyntaxQuickStart/SyntaxWalker/bin/Debug/net8.0/SyntaxWalker.dll + +roslyn-sdk/SemanticQuickStart: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/roslyn-sdk/SemanticQuickStart/bin/Debug/net8.0/SemanticQuickStart.dll + +roslyn-sdk/ConstructionCS: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/roslyn-sdk/SyntaxTransformationQuickStart/ConstructionCS/bin/Debug/net8.0/ConstructionCS.dll + +roslyn-sdk/TransformationCS: + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ + $(TEST_PATH)/csharp/roslyn-sdk/SyntaxTransformationQuickStart/TransformationCS/bin/Debug/net8.0/TransformationCS.dll + + +test: customer-relationship exploration toll-calculator mixins-with-interfaces delegates-and-events branches-quickstart \ +events expression-trees indexers list-quickstart NullableIntroduction numbers-quickstart PatternMatching versioning-new \ +versioning-override fibonacci-msbuild classes-quickstart console-linq console-webapiclient MetadataLoadContext HelloMsBuild \ +DllMapDemo AppWithPlugin AssemblyLoading cyrillic-to-latin linker linq/aggregate linq/concatenation linq/conversion linq/customsequence \ +linq/element linq/equality linq/generation linq/grouping linq/join linq/ordering linq/partitioning linq/quantifier linq/queryexecution \ +linq/restriction linq/setoperators logging/console-formatter-custom logging/console-formatter-simple logging/console-formatter-systemd \ +logging/logger-message-generator whats-new safe-efficient-code/ref-readonly-struct unit-testing/XUnit.TestProject unit-testing/NUnit.TestProject \ +unit-testing/MSTest.Project unit-testing-code-coverage roslyn-sdk/Tutorials roslyn-sdk/HelloSyntaxTree roslyn-sdk/SyntaxWalker \ No newline at end of file diff --git a/src/tests/run.sh b/src/tests/run.sh index fe809ac3b6f7f..60a75169b7069 100755 --- a/src/tests/run.sh +++ b/src/tests/run.sh @@ -53,7 +53,7 @@ repoRootDir="$(cd "$scriptPath"/../..; pwd -P)" source "$repoRootDir/eng/native/init-os-and-arch.sh" # Argument variables -buildArch="$arch" +buildArch="riscv64" buildOS= buildConfiguration="Debug" testRootDir= From c1add1464a29d42093b7889d35d75e924dcb5e12 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Mon, 18 Dec 2023 19:09:05 +0800 Subject: [PATCH 004/139] process return type ArgInFRegR4 decompose OP_ICONV_TO_OVF_* lowering & output OP_MOVE_F_TO_I*, OP_MOVE_I*_TO_F, OP_{F|R}C{LE|LT|EQ|NEQ|GT|GE}, OP_LCALL_REG --- src/mono/mono/mini/cpu-riscv64.mdesc | 6 ++ src/mono/mono/mini/mini-riscv.c | 118 ++++++++++++++++++++++----- 2 files changed, 105 insertions(+), 19 deletions(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 8eb340ea1fd2e..151381c1e20a1 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -71,6 +71,7 @@ fcall_membase: dest:f src1:b len:12 clob:c # Note: in RV32, it shoule be # lcall: dest:l ... lcall: dest:a len:16 clob:c +call_reg: dest:a src1:i len:4 clob:c lcall_membase: dest:a src1:b len:8 clob:c store_membase_reg: dest:b src1:i len:24 @@ -112,6 +113,10 @@ move: dest:i src1:i len:4 lmove: dest:i src1:i len:4 fmove: dest:f src1:f len:4 rmove: dest:f src1:f len:4 +move_f_to_i4: dest:i src1:f len:4 +move_i4_to_f: dest:f src1:i len:4 +move_f_to_i8: dest:i src1:f len:4 +move_i8_to_f: dest:f src1:i len:4 iconst: dest:i len:16 i8const: dest:i len:16 @@ -151,6 +156,7 @@ float_ceq: dest:i src1:f src2:f len:4 float_cle: dest:i src1:f src2:f len:4 float_clt: dest:i src1:f src2:f len:4 float_clt_un: dest:i src1:f src2:f len:4 +r4_ceq: dest:i src1:f src2:f len:4 r4_clt: dest:i src1:f src2:f len:4 r4_clt_un: dest:i src1:f src2:f len:4 r4_cle: dest:i src1:f src2:f len:4 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 33d5be8eb6b70..3a94e34df5c61 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1754,6 +1754,14 @@ mono_arch_emit_setret (MonoCompile *cfg, MonoMethod *method, MonoInst *val) case ArgInFReg: MONO_EMIT_NEW_UNALU (cfg, OP_FMOVE, cfg->ret->dreg, val->dreg); break; +#ifdef TARGET_RISCV64 + case ArgInFRegR4: + if (COMPILE_LLVM (cfg)) + NOT_IMPLEMENTED; + else + MONO_EMIT_NEW_UNALU (cfg, OP_RMOVE, cfg->ret->dreg, val->dreg); + break; +#endif default: g_print ("can't process Storage type %d\n", cinfo->ret.storage); NOT_IMPLEMENTED; @@ -1865,14 +1873,24 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LREM_UN: case OP_IREM_UN_IMM: + case OP_ICONV_TO_OVF_I1: + case OP_ICONV_TO_OVF_I1_UN: case OP_ICONV_TO_OVF_U1: case OP_ICONV_TO_OVF_U1_UN: + case OP_ICONV_TO_OVF_I2: + case OP_ICONV_TO_OVF_I2_UN: case OP_ICONV_TO_OVF_U2: case OP_ICONV_TO_OVF_U2_UN: + case OP_ICONV_TO_OVF_I8: + case OP_ICONV_TO_OVF_I8_UN: case OP_ICONV_TO_OVF_U4: case OP_ICONV_TO_OVF_U4_UN: + case OP_ICONV_TO_OVF_I8: + case OP_ICONV_TO_OVF_I8_UN: case OP_ICONV_TO_OVF_U8: case OP_ICONV_TO_OVF_U8_UN: + case OP_ICONV_TO_OVF_I_UN: + case OP_ICONV_TO_OVF_U_UN: case OP_LCONV_TO_OVF_I: case OP_LCONV_TO_OVF_U: case OP_LCONV_TO_OVF_U1: @@ -1958,6 +1976,9 @@ mono_arch_allocate_vars (MonoCompile *cfg) break; case ArgInIReg: case ArgInFReg: +#ifdef TARGET_RISCV64 + case ArgInFRegR4: +#endif cfg->ret->opcode = OP_REGVAR; cfg->ret->inst_c0 = cinfo->ret.reg; cfg->ret->dreg = cinfo->ret.reg; @@ -2196,6 +2217,12 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_MOVE: case OP_RMOVE: case OP_FMOVE: + case OP_MOVE_F_TO_I4: + case OP_MOVE_I4_TO_F: +#ifdef TARGET_RISCV64 + case OP_MOVE_F_TO_I8: + case OP_MOVE_I8_TO_F: +#endif case OP_LMOVE: case OP_ISUB: case OP_LSUB: @@ -2294,14 +2321,60 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_FCONV_TO_R4: case OP_FCONV_TO_I8: case OP_FCEQ: + case OP_FCLE: case OP_FCLT: + case OP_FCLT_UN: + case OP_RCEQ: + case OP_RCLE: case OP_RCLT: case OP_RCLT_UN: - case OP_FCLT_UN: case OP_RISCV_SETFREG_R4: case OP_R4CONST: case OP_ICONV_TO_R4: break; + case OP_RCGT: + case OP_RCGT_UN: { + // rcgt rd, rs1, rs2 -> rlt rd, rs2, rs1 + ins->opcode = OP_RCLT; + int tmp_reg = ins->sreg1; + ins->sreg1 = ins->sreg2; + ins->sreg2 = tmp_reg; + break; + } + case OP_RCGE: + case OP_FCGE:{ + // rcge rd, rs1, rs2 -> rcle rd, rs2, rs1 + if (ins->opcode == OP_FCGE) + ins->opcode = OP_FCLE; + else + ins->opcode = OP_RCLE; + int tmp_reg = ins->sreg1; + ins->sreg1 = ins->sreg2; + ins->sreg2 = tmp_reg; + break; + } + case OP_RCNEQ: + case OP_FCNEQ:{ + // fcneq rd, rs1, rs2 -> fceq rd, rs1, rs2, ceq rd, rd, zero + if (ins->opcode == OP_FCNEQ) + ins->opcode = OP_FCEQ; + else + ins->opcode = OP_RCEQ; + NEW_INS_AFTER (cfg, ins, temp, OP_CEQ); + temp->dreg = ins->dreg; + temp->sreg1 = temp->dreg; + temp->sreg2 = RISCV_ZERO; + break; + } + case OP_FCGT: + case OP_FCGT_UN: { + // fcgt rd, rs1, rs2 -> flt rd, rs2, rs1 + ins->opcode = OP_FCLT; + int tmp_reg = ins->sreg1; + ins->sreg1 = ins->sreg2; + ins->sreg2 = tmp_reg; + break; + } case OP_FCONV_TO_I2: case OP_RCONV_TO_I2: { // fconv_to_i2 rd, fs1 => fconv_to_i{4|8} rs1, fs1; {i|l}conv_to_i2 rd, rs1 @@ -2327,24 +2400,6 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->sreg1 = temp->dreg; goto loop_start; } - case OP_RCGT: - case OP_RCGT_UN: { - // rcgt rd, rs1, rs2 -> rlt rd, rs2, rs1 - ins->opcode = OP_RCLT; - int tmp_reg = ins->sreg1; - ins->sreg1 = ins->sreg2; - ins->sreg2 = tmp_reg; - break; - } - case OP_FCGT: - case OP_FCGT_UN: { - // fcgt rd, rs1, rs2 -> flt rd, rs2, rs1 - ins->opcode = OP_FCLT; - int tmp_reg = ins->sreg1; - ins->sreg1 = ins->sreg2; - ins->sreg2 = tmp_reg; - break; - } case OP_RCOMPARE: { if (ins->next) { if (ins->next->opcode == OP_FBLT || ins->next->opcode == OP_FBLT_UN) { @@ -2492,6 +2547,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) } break; case OP_CALL_REG: + case OP_LCALL_REG: case OP_FCALL_REG: case OP_VOIDCALL_REG: case OP_VCALL2_REG: @@ -4115,6 +4171,24 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) else riscv_fsgnj_s (code, ins->dreg, ins->sreg1, ins->sreg1); break; + case OP_MOVE_F_TO_I4: + g_assert (riscv_stdext_f); + riscv_fmv_x_w (code, ins->dreg, ins->sreg1); + break; + case OP_MOVE_I4_TO_F: + g_assert (riscv_stdext_f); + riscv_fmv_w_x (code, ins->dreg, ins->sreg1); + break; +#ifdef TARGET_RISCV64 + case OP_MOVE_F_TO_I8: + g_assert (riscv_stdext_d); + riscv_fmv_x_d (code, ins->dreg, ins->sreg1); + break; + case OP_MOVE_I8_TO_F: + g_assert (riscv_stdext_d); + riscv_fmv_d_x (code, ins->dreg, ins->sreg1); + break; +#endif case OP_LOAD_MEMBASE: code = mono_riscv_emit_load (code, ins->dreg, ins->sreg1, ins->inst_offset, 0); break; @@ -4583,6 +4657,11 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_feq_s (code, ins->dreg, ins->sreg1, ins->sreg2); break; } + case OP_RCEQ: { + g_assert (riscv_stdext_f); + riscv_feq_s (code, ins->dreg, ins->sreg1, ins->sreg2); + break; + } case OP_RCLT: case OP_RCLT_UN: { g_assert (riscv_stdext_f); @@ -4656,6 +4735,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) break; } case OP_CALL_REG: + case OP_LCALL_REG: case OP_RCALL_REG: case OP_FCALL_REG: case OP_VOIDCALL_REG: From 58242e8caf332a98d15949ac4eaca41cb894f09e Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Mon, 18 Dec 2023 19:33:11 +0800 Subject: [PATCH 005/139] remove unusable var --- src/mono/mono/mini/exceptions-riscv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/exceptions-riscv.c b/src/mono/mono/mini/exceptions-riscv.c index fec9d18fafb60..d9a888dd89860 100644 --- a/src/mono/mono/mini/exceptions-riscv.c +++ b/src/mono/mono/mini/exceptions-riscv.c @@ -114,7 +114,7 @@ mono_arch_get_call_filter (MonoTrampInfo **info, gboolean aot) { guint8 *code; guint8 *start; - int i, size, offset, gregs_offset, fregs_offset, ctx_offset, num_fregs, frame_size; + int size, offset, gregs_offset, fregs_offset, ctx_offset, frame_size; MonoJumpInfo *ji = NULL; GSList *unwind_ops = NULL; From 22a71ffd5cb568c69894afa615bf1377e46d4eda Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:31:35 +0800 Subject: [PATCH 006/139] Create jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/jit-riscv64.yml diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml new file mode 100644 index 0000000000000..f61d711736066 --- /dev/null +++ b/.github/workflows/jit-riscv64.yml @@ -0,0 +1,40 @@ +on: + push: + branches: + - riscv-jit-rv64 + +jobs: + cross-build: + runs-on: ubuntu-latest + container: + image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-riscv64 + env: + ROOTFS_DIR: /crossrootfs/riscv64 + QEMU_LD_PREFIX: /crossrootfs/riscv64 + steps: + - name: Cross Build + # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build + run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci + - name: Build Tests programs + run: cd src/tests && ./build.sh -mono -debug riscv64 -ninja -tree:JIT/ --ci + # upload entire project + - name: Upload Artifacts + uses: actions/upload-artifact@v2 + with: + name: jit-riscv64 + path: ./ + + test: + runs-on: ubuntu-latest + container: + image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-riscv64 + env: + ROOTFS_DIR: /crossrootfs/riscv64 + QEMU_LD_PREFIX: /crossrootfs/riscv64 + steps: + - name: Download Artifacts + uses: actions/download-artifact@v2 + with: + name: jit-riscv64 + - name: Run tests + run: cd src/tests && ./run.sh Release From e441848e16ecbea0e4440f3932f39159ed878510 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:33:40 +0800 Subject: [PATCH 007/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index f61d711736066..77f9a90154250 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -12,6 +12,8 @@ jobs: ROOTFS_DIR: /crossrootfs/riscv64 QEMU_LD_PREFIX: /crossrootfs/riscv64 steps: + - name: check path + run: pwd - name: Cross Build # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci From 698197eed62cfd431190847fde62fc0ed82b22fb Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:35:00 +0800 Subject: [PATCH 008/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 77f9a90154250..693d793dc294c 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -13,7 +13,7 @@ jobs: QEMU_LD_PREFIX: /crossrootfs/riscv64 steps: - name: check path - run: pwd + run: ls - name: Cross Build # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci From ad72dd1421bf1367fcbf1f7cb25ce06c7d4cd890 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:39:35 +0800 Subject: [PATCH 009/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 693d793dc294c..e2d82be9ef870 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -12,13 +12,11 @@ jobs: ROOTFS_DIR: /crossrootfs/riscv64 QEMU_LD_PREFIX: /crossrootfs/riscv64 steps: - - name: check path - run: ls - name: Cross Build # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build - run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci + run: bash -c ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci - name: Build Tests programs - run: cd src/tests && ./build.sh -mono -debug riscv64 -ninja -tree:JIT/ --ci + run: cd src/tests && bash -c ./build.sh -mono -debug riscv64 -ninja -tree:JIT/ --ci # upload entire project - name: Upload Artifacts uses: actions/upload-artifact@v2 @@ -33,10 +31,12 @@ jobs: env: ROOTFS_DIR: /crossrootfs/riscv64 QEMU_LD_PREFIX: /crossrootfs/riscv64 + needs: cross-build steps: - name: Download Artifacts uses: actions/download-artifact@v2 with: name: jit-riscv64 - name: Run tests - run: cd src/tests && ./run.sh Release + run: cd src/tests && bash -c ./run.sh Release + From 9104218f32de2dd22f92e3f1d00f7d29fab74729 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:41:48 +0800 Subject: [PATCH 010/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index e2d82be9ef870..60d08555badb8 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -12,6 +12,8 @@ jobs: ROOTFS_DIR: /crossrootfs/riscv64 QEMU_LD_PREFIX: /crossrootfs/riscv64 steps: + - name: check current path + run: bash -c ls -la - name: Cross Build # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: bash -c ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci From 61bdf12a122835e63e2eec01f624a38d1d6ab418 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:44:36 +0800 Subject: [PATCH 011/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 60d08555badb8..fc1570c327770 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -13,12 +13,14 @@ jobs: QEMU_LD_PREFIX: /crossrootfs/riscv64 steps: - name: check current path - run: bash -c ls -la + run: | + bash -c ls -la - name: Cross Build # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: bash -c ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci - name: Build Tests programs - run: cd src/tests && bash -c ./build.sh -mono -debug riscv64 -ninja -tree:JIT/ --ci + run: | + cd src/tests && bash -c ./build.sh -mono -debug riscv64 -ninja -tree:JIT/ --ci # upload entire project - name: Upload Artifacts uses: actions/upload-artifact@v2 @@ -40,5 +42,6 @@ jobs: with: name: jit-riscv64 - name: Run tests - run: cd src/tests && bash -c ./run.sh Release + run: | + cd src/tests && bash -c ./run.sh Release From ed6dadff094d6c1c21fe35759848ca15f8130073 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:49:57 +0800 Subject: [PATCH 012/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index fc1570c327770..c38ed56176c33 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -12,21 +12,22 @@ jobs: ROOTFS_DIR: /crossrootfs/riscv64 QEMU_LD_PREFIX: /crossrootfs/riscv64 steps: - - name: check current path - run: | - bash -c ls -la + - name: Checkout + uses: actions/checkout@v2 - name: Cross Build # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build - run: bash -c ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci + run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci + working-directory: ./runtime - name: Build Tests programs - run: | - cd src/tests && bash -c ./build.sh -mono -debug riscv64 -ninja -tree:JIT/ --ci + run: ./build.sh -mono -debug riscv64 -ninja -tree:JIT/ --ci + working-directory: ./runtime/src/tests # upload entire project - name: Upload Artifacts uses: actions/upload-artifact@v2 with: name: jit-riscv64 path: ./ + working-directory: ./runtime test: runs-on: ubuntu-latest @@ -42,6 +43,6 @@ jobs: with: name: jit-riscv64 - name: Run tests - run: | - cd src/tests && bash -c ./run.sh Release + run: bash -c ./run.sh Release + working-directory: ./runtime/src/tests From 949dd124cc0c96a1198fbbfc023ab1286000dfa1 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:54:58 +0800 Subject: [PATCH 013/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index c38ed56176c33..d613733a57d65 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -1,4 +1,5 @@ on: + workflow_dispatch: push: branches: - riscv-jit-rv64 @@ -27,7 +28,6 @@ jobs: with: name: jit-riscv64 path: ./ - working-directory: ./runtime test: runs-on: ubuntu-latest From 179859e1aee7c6744835ec815981eb67d629cc4b Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 20:58:01 +0800 Subject: [PATCH 014/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index d613733a57d65..9cf3cfca2bdf5 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -18,10 +18,9 @@ jobs: - name: Cross Build # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci - working-directory: ./runtime - name: Build Tests programs run: ./build.sh -mono -debug riscv64 -ninja -tree:JIT/ --ci - working-directory: ./runtime/src/tests + working-directory: ./src/tests # upload entire project - name: Upload Artifacts uses: actions/upload-artifact@v2 @@ -44,5 +43,5 @@ jobs: name: jit-riscv64 - name: Run tests run: bash -c ./run.sh Release - working-directory: ./runtime/src/tests + working-directory: ./src/tests From 870767f8148b85ff007e5df6cda4faa50f72024c Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 21:13:39 +0800 Subject: [PATCH 015/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 9cf3cfca2bdf5..3824e92d77369 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -19,7 +19,7 @@ jobs: # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci - name: Build Tests programs - run: ./build.sh -mono -debug riscv64 -ninja -tree:JIT/ --ci + run: ./build.sh -mono -debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests # upload entire project - name: Upload Artifacts @@ -29,6 +29,7 @@ jobs: path: ./ test: + continue-on-error: true runs-on: ubuntu-latest container: image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-riscv64 From 38712727ffe8fe4602caeed0ae86bd1a608e3c71 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 21:25:20 +0800 Subject: [PATCH 016/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 3824e92d77369..1d23d592990e8 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -15,9 +15,20 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + - name: Cross Rebuild + continue-on-error: true + run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild - name: Cross Build + if: failure() # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci + # cache + - name: Cache + uses: actions/cache@v2 + with: + path: | + .dotnet/ + artifacts/ - name: Build Tests programs run: ./build.sh -mono -debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests @@ -42,6 +53,11 @@ jobs: uses: actions/download-artifact@v2 with: name: jit-riscv64 + - name: Cache + uses: actions/cache@v2 + with: + path: | + artifacts/tests/coreclr - name: Run tests run: bash -c ./run.sh Release working-directory: ./src/tests From 1e15afeda8990adb2348364ad28496eb70a2d685 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 21:30:01 +0800 Subject: [PATCH 017/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 1d23d592990e8..6331121e2c256 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -29,6 +29,7 @@ jobs: path: | .dotnet/ artifacts/ + key: ${{ runner.os }}-dotnet-cross-build - name: Build Tests programs run: ./build.sh -mono -debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests @@ -58,6 +59,7 @@ jobs: with: path: | artifacts/tests/coreclr + key: ${{ runner.os }}-dotnet-test - name: Run tests run: bash -c ./run.sh Release working-directory: ./src/tests From df06dff0684a88d89ebd8f8404a1164fa6bb1b7e Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 21:30:44 +0800 Subject: [PATCH 018/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 6331121e2c256..2067b52ea790a 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -29,7 +29,7 @@ jobs: path: | .dotnet/ artifacts/ - key: ${{ runner.os }}-dotnet-cross-build + key: ${{ runner.os }}-dotnet-cross-build - name: Build Tests programs run: ./build.sh -mono -debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests @@ -59,7 +59,7 @@ jobs: with: path: | artifacts/tests/coreclr - key: ${{ runner.os }}-dotnet-test + key: ${{ runner.os }}-dotnet-test - name: Run tests run: bash -c ./run.sh Release working-directory: ./src/tests From 811a10f42c92ac2d8ae31df0dc101f684e1682cd Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 21:33:32 +0800 Subject: [PATCH 019/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 2067b52ea790a..234a671d1978c 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -19,7 +19,7 @@ jobs: continue-on-error: true run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild - name: Cross Build - if: failure() + if: ${{ failure() }} # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci # cache @@ -29,7 +29,7 @@ jobs: path: | .dotnet/ artifacts/ - key: ${{ runner.os }}-dotnet-cross-build + key: ${{ runner.os }}-dotnet-cross-build - name: Build Tests programs run: ./build.sh -mono -debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests @@ -59,7 +59,7 @@ jobs: with: path: | artifacts/tests/coreclr - key: ${{ runner.os }}-dotnet-test + key: ${{ runner.os }}-dotnet-test - name: Run tests run: bash -c ./run.sh Release working-directory: ./src/tests From fa6cdb91124266aa5d43676fffdaf461784e515a Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 21:33:59 +0800 Subject: [PATCH 020/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 234a671d1978c..35329d9de4a5a 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -29,7 +29,7 @@ jobs: path: | .dotnet/ artifacts/ - key: ${{ runner.os }}-dotnet-cross-build + key: ${{ runner.os }}-dotnet-cross-build - name: Build Tests programs run: ./build.sh -mono -debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests @@ -59,7 +59,7 @@ jobs: with: path: | artifacts/tests/coreclr - key: ${{ runner.os }}-dotnet-test + key: ${{ runner.os }}-dotnet-test - name: Run tests run: bash -c ./run.sh Release working-directory: ./src/tests From 1666b4edbb941af1bf2d2b2accdf4773993d41fe Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 21:39:21 +0800 Subject: [PATCH 021/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 35329d9de4a5a..133bd3c8b688d 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -16,7 +16,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Cross Rebuild - continue-on-error: true run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild - name: Cross Build if: ${{ failure() }} From fa4248a6da461da712f27a3c889f4d97eb40e4e0 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 21:48:26 +0800 Subject: [PATCH 022/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 133bd3c8b688d..dc03a1afe1382 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -16,6 +16,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Cross Rebuild + continue-on-error: true run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild - name: Cross Build if: ${{ failure() }} @@ -30,7 +31,7 @@ jobs: artifacts/ key: ${{ runner.os }}-dotnet-cross-build - name: Build Tests programs - run: ./build.sh -mono -debug riscv64 -tree:JIT/ --ci + run: ./build.sh -mono -release riscv64 -tree:JIT/ --ci working-directory: ./src/tests # upload entire project - name: Upload Artifacts From a718fb5d3f8c4270755d8f17791754ce7381a88d Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:25:56 +0800 Subject: [PATCH 023/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index dc03a1afe1382..da070c407bc60 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -15,13 +15,18 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: Cross Rebuild - continue-on-error: true - run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild - - name: Cross Build + - name: Cross Rebuild Mono + run: ./build.sh mono -c Debug --cross --arch riscv64 --ci --rebuild + - name: Cross Build Mono if: ${{ failure() }} # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build - run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci + run: ./build.sh mono -c Debug --cross --arch riscv64 --ci + - name: Cross Rebuild Libs & host + run: ./build.sh libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild + - name: Cross Build Libs & host + if: ${{ failure() }} + # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build + run: ./build.sh libs+host+clr.hosts -c Release --cross --arch riscv64 --ci # cache - name: Cache uses: actions/cache@v2 From 6f45e767ae86ef743e0ae80e93503ef8e572faec Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:52:11 +0800 Subject: [PATCH 024/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index da070c407bc60..dd584c5aba3b4 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -21,12 +21,12 @@ jobs: if: ${{ failure() }} # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: ./build.sh mono -c Debug --cross --arch riscv64 --ci + - name: Cross Rebuild Libs & host - run: ./build.sh libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild + run: ./build.sh mono.libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild - name: Cross Build Libs & host if: ${{ failure() }} - # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build - run: ./build.sh libs+host+clr.hosts -c Release --cross --arch riscv64 --ci + run: ./build.sh mono.libs+host+clr.hosts -c Release --cross --arch riscv64 --ci # cache - name: Cache uses: actions/cache@v2 From d65073de117fd60816a2086d5198cc7b5547cfe1 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 23:05:26 +0800 Subject: [PATCH 025/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index dd584c5aba3b4..adb4e378d3617 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -23,10 +23,10 @@ jobs: run: ./build.sh mono -c Debug --cross --arch riscv64 --ci - name: Cross Rebuild Libs & host - run: ./build.sh mono.libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild + run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild - name: Cross Build Libs & host if: ${{ failure() }} - run: ./build.sh mono.libs+host+clr.hosts -c Release --cross --arch riscv64 --ci + run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci # cache - name: Cache uses: actions/cache@v2 From 74e721be7d038edb7df20cf62ec12718bb4a1329 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 23:23:37 +0800 Subject: [PATCH 026/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index adb4e378d3617..38c27a8da5ed6 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -16,6 +16,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - name: Cross Rebuild Mono + continue-on-error: true run: ./build.sh mono -c Debug --cross --arch riscv64 --ci --rebuild - name: Cross Build Mono if: ${{ failure() }} @@ -23,10 +24,14 @@ jobs: run: ./build.sh mono -c Debug --cross --arch riscv64 --ci - name: Cross Rebuild Libs & host + continue-on-error: true run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild - name: Cross Build Libs & host if: ${{ failure() }} run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci + - name: Build Tests programs + run: ./build.sh -mono -release riscv64 -tree:JIT/ --ci + working-directory: ./src/tests # cache - name: Cache uses: actions/cache@v2 @@ -35,9 +40,6 @@ jobs: .dotnet/ artifacts/ key: ${{ runner.os }}-dotnet-cross-build - - name: Build Tests programs - run: ./build.sh -mono -release riscv64 -tree:JIT/ --ci - working-directory: ./src/tests # upload entire project - name: Upload Artifacts uses: actions/upload-artifact@v2 From fba4c33ec71c724114c1dcaad1342dfb2f3251ab Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Mon, 18 Dec 2023 23:30:38 +0800 Subject: [PATCH 027/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 38c27a8da5ed6..97fa7e56f0414 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -15,19 +15,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - - name: Cross Rebuild Mono - continue-on-error: true - run: ./build.sh mono -c Debug --cross --arch riscv64 --ci --rebuild - name: Cross Build Mono - if: ${{ failure() }} # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: ./build.sh mono -c Debug --cross --arch riscv64 --ci - - - name: Cross Rebuild Libs & host - continue-on-error: true - run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci --rebuild - name: Cross Build Libs & host - if: ${{ failure() }} run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci - name: Build Tests programs run: ./build.sh -mono -release riscv64 -tree:JIT/ --ci From 47939db949af1d762fcb8d164552cea78f923ed7 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Mon, 18 Dec 2023 23:59:49 +0800 Subject: [PATCH 028/139] dump asm --- src/mono/mono/mini/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/helpers.c b/src/mono/mono/mini/helpers.c index 9d903fdbc24a5..83a72abfa2173 100644 --- a/src/mono/mono/mini/helpers.c +++ b/src/mono/mono/mini/helpers.c @@ -274,7 +274,7 @@ MONO_RESTORE_WARNING g_free (cmd); #endif - cmd = g_strdup_printf (ARCH_PREFIX DIS_CMD " %s %s", objdump_args, o_file); + cmd = g_strdup_printf ("llvm-objdump -d --arch=rv64gc %s %s", objdump_args, o_file); unused = system (cmd); g_free (cmd); g_free (objdump_args); From 7a7d671221e3f261ddad08aa2bc56a67a9e1b6aa Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Tue, 19 Dec 2023 12:45:45 +0800 Subject: [PATCH 029/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 97fa7e56f0414..2f35a83ad6c1e 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -15,6 +15,15 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 + # cache + - name: Cache + uses: actions/cache@v2 + with: + path: | + .dotnet/ + artifacts/ + key: ${{ runner.os }}-dotnet-cross-build + - name: Cross Build Mono # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build run: ./build.sh mono -c Debug --cross --arch riscv64 --ci @@ -23,20 +32,15 @@ jobs: - name: Build Tests programs run: ./build.sh -mono -release riscv64 -tree:JIT/ --ci working-directory: ./src/tests - # cache - - name: Cache - uses: actions/cache@v2 - with: - path: | - .dotnet/ - artifacts/ - key: ${{ runner.os }}-dotnet-cross-build + + - name: compress files + run: tar -zcvf runtime.tar.gz ./* # upload entire project - name: Upload Artifacts uses: actions/upload-artifact@v2 with: name: jit-riscv64 - path: ./ + path: ./runtime.tar.gz test: continue-on-error: true @@ -52,6 +56,8 @@ jobs: uses: actions/download-artifact@v2 with: name: jit-riscv64 + - name: Decompress + run: tar -zxvf runtime.tar.gz ./* - name: Cache uses: actions/cache@v2 with: From 555fe6010a2c5222c0ff31941431309dead765a0 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 13:45:05 +0800 Subject: [PATCH 030/139] tailcall --- src/mono/mono/mini/cpu-riscv64.mdesc | 7 +- src/mono/mono/mini/mini-riscv.c | 110 ++++++++++++++++++++++++++- src/mono/mono/mini/mini-riscv.h | 9 ++- 3 files changed, 118 insertions(+), 8 deletions(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 151381c1e20a1..0f4f2c4d04298 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -71,9 +71,14 @@ fcall_membase: dest:f src1:b len:12 clob:c # Note: in RV32, it shoule be # lcall: dest:l ... lcall: dest:a len:16 clob:c -call_reg: dest:a src1:i len:4 clob:c +lcall_reg: dest:a src1:i len:4 clob:c lcall_membase: dest:a src1:b len:8 clob:c +tailcall_parameter: len:24 +tailcall: len:24 clob:c +tailcall_membase: src1:b len:24 clob:c +tailcall_reg: src1:b len:24 clob:c + store_membase_reg: dest:b src1:i len:24 storei1_membase_reg: dest:b src1:i len:24 storei2_membase_reg: dest:b src1:i len:24 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 3a94e34df5c61..5c30537229df9 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1278,7 +1278,36 @@ mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode) gboolean mono_arch_tailcall_supported (MonoCompile *cfg, MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig, gboolean virtual_) { - NOT_IMPLEMENTED; + g_assert (caller_sig); + g_assert (callee_sig); + + CallInfo *caller_info = get_call_info (NULL, caller_sig); + CallInfo *callee_info = get_call_info (NULL, callee_sig); + + // Do not tail call optimize functions with varargs passed by stack. + gboolean res = IS_SUPPORTED_TAILCALL(callee_sig->call_convention != MONO_CALL_VARARG); + + // Byval parameters hand the function a pointer directly into the stack area + // we want to reuse during a tail call. Do not tail call optimize functions with + // byval parameters. + // + // Do not tail call optimize if stack is used to pass parameters. + const ArgInfo *ainfo; + ainfo = callee_info->args + callee_sig->hasthis; + for (int i = 0; res && i < callee_sig->param_count; ++i) { + res == IS_SUPPORTED_TAILCALL (ainfo [i].storage < ArgOnStack); + } + + // Do not tail call optimize if callee uses structret semantics. + res &= IS_SUPPORTED_TAILCALL (callee_info->ret.storage < ArgVtypeByRef); + + // Do not tail call optimize if caller uses structret semantics. + res &= IS_SUPPORTED_TAILCALL (caller_info->ret.storage < ArgVtypeByRef); + + g_free (caller_info); + g_free (callee_info); + + return res; } gboolean @@ -1885,8 +1914,6 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_OVF_I8_UN: case OP_ICONV_TO_OVF_U4: case OP_ICONV_TO_OVF_U4_UN: - case OP_ICONV_TO_OVF_I8: - case OP_ICONV_TO_OVF_I8_UN: case OP_ICONV_TO_OVF_U8: case OP_ICONV_TO_OVF_U8_UN: case OP_ICONV_TO_OVF_I_UN: @@ -2200,6 +2227,10 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_BR: case OP_BR_REG: case OP_JUMP_TABLE: + case OP_TAILCALL_PARAMETER: + case OP_TAILCALL: + case OP_TAILCALL_REG: + case OP_TAILCALL_MEMBASE: case OP_CALL: case OP_RCALL: case OP_FCALL: @@ -4720,6 +4751,79 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) } /* Calls */ + case OP_TAILCALL_PARAMETER: + // This opcode helps compute sizes, i.e. + // of the subsequent OP_TAILCALL, but contributes no code. + g_assert (ins->next); + break; + case OP_TAILCALL: + case OP_TAILCALL_REG: + case OP_TAILCALL_MEMBASE: { + int target_reg = RISCV_T1; + guint64 free_reg = 1 << RISCV_T1; + call = (MonoCallInst*)ins; + + g_assert (!cfg->method->save_lmf); + + switch (ins->opcode) { + case OP_TAILCALL: + break; + case OP_TAILCALL_REG: + g_assert (ins->sreg1 != -1); + g_assert (ins->sreg1 != RISCV_T0); + g_assert (ins->sreg1 != RISCV_T1); + g_assert (ins->sreg1 != RISCV_RA); + g_assert (ins->sreg1 != RISCV_SP); + g_assert (ins->sreg1 != RISCV_FP); + riscv_addi (code, target_reg, ins->sreg1, 0); + break; + case OP_TAILCALL_MEMBASE: + g_assert (ins->sreg1 != -1); + g_assert (ins->sreg1 != RISCV_T0); + g_assert (ins->sreg1 != RISCV_T1); + g_assert (ins->sreg1 != RISCV_RA); + g_assert (ins->sreg1 != RISCV_SP); + g_assert (ins->sreg1 != RISCV_FP); + code = mono_riscv_emit_load (code, target_reg, ins->inst_basereg, ins->inst_offset, 0); + break; + default: + g_assert_not_reached (); + } + + g_assert(call->stack_usage == 0); + + /* Restore registers */ + code = mono_riscv_emit_load_stack (code, MONO_ARCH_CALLEE_SAVED_REGS & cfg->used_int_regs, RISCV_FP, + -cfg->arch.saved_gregs_offset, FALSE); + + /* Destroy frame */ + code = mono_riscv_emit_destroy_frame (code); + + switch (ins->opcode) { + case OP_TAILCALL: + if(cfg->compile_aot){ + NOT_IMPLEMENTED; + } + else{ + mono_add_patch_info_rel (cfg, GPTRDIFF_TO_INT (code - cfg->native_code), MONO_PATCH_INFO_METHOD_JUMP, call->method, MONO_R_RISCV_JAL); + riscv_jal (code, RISCV_ZERO, 0); + } + break; + case OP_TAILCALL_REG: + case OP_TAILCALL_MEMBASE: + // code = mono_arm_emit_brx (code, branch_reg); + riscv_jalr (code, RISCV_ZERO, target_reg, 0); + break; + + default: + g_assert_not_reached (); + } + + ins->flags |= MONO_INST_GC_CALLSITE; + ins->backend.pc_offset = GPTRDIFF_TO_INT (code - cfg->native_code); + + break; + } case OP_VOIDCALL: case OP_CALL: case OP_RCALL: diff --git a/src/mono/mono/mini/mini-riscv.h b/src/mono/mono/mini/mini-riscv.h index c03905f038d37..8cef6420e3438 100644 --- a/src/mono/mono/mini/mini-riscv.h +++ b/src/mono/mono/mini/mini-riscv.h @@ -232,23 +232,24 @@ typedef struct { } CallContext; typedef enum { + ArgNone, // only in void return type ArgInIReg = 0x01, - ArgOnStack, ArgInFReg, #ifdef TARGET_RISCV64 ArgInFRegR4, #endif + ArgOnStack, ArgOnStackR4, ArgOnStackR8, + /* * Vtype passed in consecutive int registers. */ + ArgVtypeInIReg, ArgVtypeByRef, ArgVtypeByRefOnStack, ArgVtypeOnStack, - ArgVtypeInIReg, - ArgVtypeInMixed, - ArgNone // only in void return type + ArgVtypeInMixed } ArgStorage; typedef struct { From ccc2ea74aabef045d2123d1e0ec6e57e6cb98b64 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 14:21:27 +0800 Subject: [PATCH 031/139] r4_add --- src/mono/mono/mini/cpu-riscv64.mdesc | 1 + src/mono/mono/mini/mini-riscv.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 0f4f2c4d04298..3b2a55b59b13d 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -127,6 +127,7 @@ iconst: dest:i len:16 i8const: dest:i len:16 int_add: dest:i src1:i src2:i len:4 long_add: dest:i src1:i src2:i len:4 +r4_add: dest:f src1:f src2:f len:4 float_add: dest:f src1:f src2:f len:4 int_sub: dest:i src1:i src2:i len:4 long_sub: dest:i src1:i src2:i len:4 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 5c30537229df9..db9ce75dd0e1f 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1806,6 +1806,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_IADD: case OP_IADD_IMM: case OP_IADD_OVF: + case OP_RADD: case OP_FADD: case OP_ISUB: case OP_LSUB: @@ -2342,6 +2343,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) /* Float Ext */ case OP_R8CONST: + case OP_RADD: case OP_FADD: case OP_FNEG: case OP_ICONV_TO_R8: @@ -4278,6 +4280,10 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_LADD_IMM: riscv_addi (code, ins->dreg, ins->sreg1, ins->inst_imm); break; + case OP_RADD: + g_assert (riscv_stdext_f); + riscv_fadd_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); + break; case OP_FADD: g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) From 3d5ad223b8bf571726be68a0b24fd31f8f5a0c89 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 14:24:04 +0800 Subject: [PATCH 032/139] update yml --- .github/workflows/jit-riscv64.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 2f35a83ad6c1e..69dccf7da1d63 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -34,7 +34,7 @@ jobs: working-directory: ./src/tests - name: compress files - run: tar -zcvf runtime.tar.gz ./* + run: tar -zcf runtime.tar.gz ./* # upload entire project - name: Upload Artifacts uses: actions/upload-artifact@v2 @@ -57,13 +57,7 @@ jobs: with: name: jit-riscv64 - name: Decompress - run: tar -zxvf runtime.tar.gz ./* - - name: Cache - uses: actions/cache@v2 - with: - path: | - artifacts/tests/coreclr - key: ${{ runner.os }}-dotnet-test + run: tar -zxvf runtime.tar.gz -P -C /__w/runtime/runtime - name: Run tests run: bash -c ./run.sh Release working-directory: ./src/tests From c1a3128f1ca383ab752582f653b982a31892242f Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 14:24:30 +0800 Subject: [PATCH 033/139] update yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 69dccf7da1d63..9c2eaaf2885a9 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -57,7 +57,7 @@ jobs: with: name: jit-riscv64 - name: Decompress - run: tar -zxvf runtime.tar.gz -P -C /__w/runtime/runtime + run: tar -zxf runtime.tar.gz -P -C /__w/runtime/runtime - name: Run tests run: bash -c ./run.sh Release working-directory: ./src/tests From d949282129b65d2f4f51b6c4152a468663b2e124 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 14:26:46 +0800 Subject: [PATCH 034/139] update yml --- .github/workflows/jit-riscv64.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 9c2eaaf2885a9..877f4be6eedd8 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -39,7 +39,7 @@ jobs: - name: Upload Artifacts uses: actions/upload-artifact@v2 with: - name: jit-riscv64 + name: runtime.tar.gz path: ./runtime.tar.gz test: @@ -55,9 +55,9 @@ jobs: - name: Download Artifacts uses: actions/download-artifact@v2 with: - name: jit-riscv64 + name: runtime.tar.gz - name: Decompress - run: tar -zxf runtime.tar.gz -P -C /__w/runtime/runtime + run: tar -zxf runtime.tar.gz -C ./ - name: Run tests run: bash -c ./run.sh Release working-directory: ./src/tests From 33deb9717374376297d041b3f00006e11b504648 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 15:01:46 +0800 Subject: [PATCH 035/139] update yml --- .github/workflows/jit-riscv64.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 877f4be6eedd8..ae83f880f5bc4 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -29,9 +29,6 @@ jobs: run: ./build.sh mono -c Debug --cross --arch riscv64 --ci - name: Cross Build Libs & host run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci - - name: Build Tests programs - run: ./build.sh -mono -release riscv64 -tree:JIT/ --ci - working-directory: ./src/tests - name: compress files run: tar -zcf runtime.tar.gz ./* @@ -58,6 +55,15 @@ jobs: name: runtime.tar.gz - name: Decompress run: tar -zxf runtime.tar.gz -C ./ + - name: Cache + uses: actions/cache@v2 + with: + path: | + artifacts/tests/ + key: ${{ runner.os }}-dotnet-cross-build + - name: Build Tests programs + run: ./build.sh -mono -release riscv64 -tree:JIT/ --ci + working-directory: ./src/tests - name: Run tests run: bash -c ./run.sh Release working-directory: ./src/tests From e8bb8d2d0827c1ab3172e8f0fa15a64d8f6170c9 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 15:13:23 +0800 Subject: [PATCH 036/139] update yml --- .github/workflows/jit-riscv64.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index ae83f880f5bc4..f85bda1347d12 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -31,7 +31,7 @@ jobs: run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci - name: compress files - run: tar -zcf runtime.tar.gz ./* + run: tar -zcf runtime.tar.gz ./.dotnet ./artifacts # upload entire project - name: Upload Artifacts uses: actions/upload-artifact@v2 @@ -47,14 +47,17 @@ jobs: env: ROOTFS_DIR: /crossrootfs/riscv64 QEMU_LD_PREFIX: /crossrootfs/riscv64 + CORE_ROOT: /crossrootfs/riscv64 needs: cross-build steps: + - name: Checkout + uses: actions/checkout@v2 - name: Download Artifacts uses: actions/download-artifact@v2 with: name: runtime.tar.gz - name: Decompress - run: tar -zxf runtime.tar.gz -C ./ + run: tar -zxf runtime.tar.gz -C ./ - name: Cache uses: actions/cache@v2 with: From 07f2601710c72186ed44ff07f9d359b9c1f470b3 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 16:35:01 +0800 Subject: [PATCH 037/139] OP_LCONV_TO_R4 --- src/mono/mono/mini/cpu-riscv64.mdesc | 4 ++-- src/mono/mono/mini/mini-riscv.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 3b2a55b59b13d..45e0ff7e79543 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -84,8 +84,8 @@ storei1_membase_reg: dest:b src1:i len:24 storei2_membase_reg: dest:b src1:i len:24 storei4_membase_reg: dest:b src1:i len:24 storei8_membase_reg: dest:b src1:i len:24 -storer4_membase_reg: dest:b src1:f len:4 -storer8_membase_reg: dest:b src1:f len:4 +storer4_membase_reg: dest:b src1:f len:24 +storer8_membase_reg: dest:b src1:f len:24 load_membase: dest:i src1:b len:24 loadu1_membase: dest:i src1:b len:24 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index db9ce75dd0e1f..4ff7152c2b774 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1830,6 +1830,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_R_UN: case OP_LCONV_TO_R_UN: case OP_ICONV_TO_R4: + case OP_LCONV_TO_R4: case OP_RCONV_TO_R8: #ifdef TARGET_RISCV64 case OP_LXOR_IMM: @@ -4766,7 +4767,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_TAILCALL_REG: case OP_TAILCALL_MEMBASE: { int target_reg = RISCV_T1; - guint64 free_reg = 1 << RISCV_T1; call = (MonoCallInst*)ins; g_assert (!cfg->method->save_lmf); From 16b83622cc188773e8270fe13d72541bf0d441ed Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 16:35:11 +0800 Subject: [PATCH 038/139] update yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index f85bda1347d12..5ef097ee0500b 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -47,7 +47,7 @@ jobs: env: ROOTFS_DIR: /crossrootfs/riscv64 QEMU_LD_PREFIX: /crossrootfs/riscv64 - CORE_ROOT: /crossrootfs/riscv64 + CORE_ROOT: /__w/runtime/runtime/artifacts/tests/coreclr/linux.riscv64.Debug/Tests/Core_Root needs: cross-build steps: - name: Checkout From 400f3724badd8385189db6e109d46aa448cc72b8 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 16:48:40 +0800 Subject: [PATCH 039/139] OP_RSUB --- src/mono/mono/mini/cpu-riscv64.mdesc | 46 ++++++++++++++++------------ src/mono/mono/mini/mini-riscv.c | 8 +++++ 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 45e0ff7e79543..cd5b439384dc3 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -124,32 +124,37 @@ move_f_to_i8: dest:i src1:f len:4 move_i8_to_f: dest:f src1:i len:4 iconst: dest:i len:16 -i8const: dest:i len:16 int_add: dest:i src1:i src2:i len:4 -long_add: dest:i src1:i src2:i len:4 -r4_add: dest:f src1:f src2:f len:4 -float_add: dest:f src1:f src2:f len:4 int_sub: dest:i src1:i src2:i len:4 -long_sub: dest:i src1:i src2:i len:4 -float_sub: dest:f src1:f src2:f len:4 -float_neg: dest:f src1:f len:4 int_mul: dest:i src1:i src2:i len:4 -r4_mul: dest:f src1:f src2:f len:4 -long_mul: dest:i src1:i src2:i len:4 -float_mul: dest:f src1:f src2:f len:4 int_div: dest:i src1:i src2:i len:32 -long_div: dest:i src1:i src2:i len:32 int_div_un: dest:i src1:i src2:i len:32 -long_div_un: dest:i src1:i src2:i len:32 -r4_div: dest:f src1:f src2:f len:36 -float_div: dest:f src1:f src2:f len:36 int_rem: dest:i src1:i src2:i len:32 -long_rem: dest:i src1:i src2:i len:32 int_rem_un: dest:i src1:i src2:i len:32 + +i8const: dest:i len:16 +long_add: dest:i src1:i src2:i len:4 +long_sub: dest:i src1:i src2:i len:4 +long_mul: dest:i src1:i src2:i len:4 +long_div: dest:i src1:i src2:i len:32 +long_div_un: dest:i src1:i src2:i len:32 +long_rem: dest:i src1:i src2:i len:32 long_rem_un: dest:i src1:i src2:i len:32 -r4const: dest:f len:16 r8const: dest:f len:16 +float_neg: dest:f src1:f len:4 +float_add: dest:f src1:f src2:f len:4 +float_sub: dest:f src1:f src2:f len:4 +float_mul: dest:f src1:f src2:f len:4 +float_div: dest:f src1:f src2:f len:36 + +r4const: dest:f len:16 +r4_add: dest:f src1:f src2:f len:4 +r4_sub: dest:f src1:f src2:f len:4 +r4_mul: dest:f src1:f src2:f len:4 +r4_div: dest:f src1:f src2:f len:36 + + int_conv_to_r4: dest:f src1:i len:4 int_conv_to_r8: dest:f src1:i len:4 r4_conv_to_i8: dest:i src1:f len:4 @@ -158,14 +163,15 @@ r4_conv_to_i4: dest:i src1:f len:4 float_conv_to_i4: dest:i src1:f len:4 float_conv_to_r4: dest:f src1:f len:4 float_conv_to_i8: dest:i src1:f len:4 -float_ceq: dest:i src1:f src2:f len:4 -float_cle: dest:i src1:f src2:f len:4 -float_clt: dest:i src1:f src2:f len:4 -float_clt_un: dest:i src1:f src2:f len:4 + r4_ceq: dest:i src1:f src2:f len:4 r4_clt: dest:i src1:f src2:f len:4 r4_clt_un: dest:i src1:f src2:f len:4 r4_cle: dest:i src1:f src2:f len:4 +float_ceq: dest:i src1:f src2:f len:4 +float_cle: dest:i src1:f src2:f len:4 +float_clt: dest:i src1:f src2:f len:4 +float_clt_un: dest:i src1:f src2:f len:4 add_imm: dest:i src1:i len:4 int_add_imm: dest:i src1:i len:4 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 4ff7152c2b774..33ece37be1133 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1229,6 +1229,7 @@ mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode) case OP_FADD: case OP_FSUB: + case OP_RSUB: case OP_FDIV: case OP_RDIV: case OP_FMUL: @@ -1811,6 +1812,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ISUB: case OP_LSUB: case OP_FSUB: + case OP_RSUB: case OP_ISUB_IMM: case OP_LSUB_IMM: case OP_ISUB_OVF: @@ -2260,6 +2262,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_ISUB: case OP_LSUB: case OP_FSUB: + case OP_RSUB: case OP_IADD: case OP_LADD: case OP_IMUL: @@ -4311,6 +4314,11 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fsub_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); } break; + case OP_RSUB: + g_assert (riscv_stdext_f); + riscv_fsub_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); + break; + } case OP_FNEG: g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) From c91e50db3c9e836f7c437df4801819bb42d9e43e Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 16:49:20 +0800 Subject: [PATCH 040/139] remove assert for lowering OP_STORER4_MEMBASE_REG --- src/mono/mono/mini/mini-riscv.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 33ece37be1133..6bd5dae6e054a 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1807,6 +1807,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_IADD: case OP_IADD_IMM: case OP_IADD_OVF: + case OP_IADD_OVF_UN: case OP_RADD: case OP_FADD: case OP_ISUB: @@ -2657,13 +2658,10 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) NEW_INS_BEFORE (cfg, ins, temp, OP_FCONV_TO_R4); temp->dreg = mono_alloc_freg (cfg); temp->sreg1 = ins->sreg1; - ins->sreg1 = temp->dreg; } // check if offset is valid I-type Imm if (!RISCV_VALID_I_IMM (ins->inst_offset)) { - g_assert (ins->opcode != OP_STORER4_MEMBASE_REG); - /** * iconst t0, offset * add t0, rd, t0 From abc76bad90908e26364c994a5b574f8192c7f352 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 16:51:54 +0800 Subject: [PATCH 041/139] fix --- src/mono/mono/mini/mini-riscv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 6bd5dae6e054a..2d3988283925e 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -4316,7 +4316,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) g_assert (riscv_stdext_f); riscv_fsub_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); break; - } case OP_FNEG: g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) From d461a1408509b918ab92ae87c3d8de4f156e2dc8 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 16:58:29 +0800 Subject: [PATCH 042/139] OP_FBEQ --- src/mono/mono/mini/mini-riscv.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 2d3988283925e..65d3f73e614a4 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1925,6 +1925,8 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_OVF_U_UN: case OP_LCONV_TO_OVF_I: case OP_LCONV_TO_OVF_U: + case OP_LCONV_TO_OVF_I1: + case OP_LCONV_TO_OVF_I1_OVF: case OP_LCONV_TO_OVF_U1: case OP_LCONV_TO_OVF_U1_UN: case OP_LCONV_TO_OVF_U2: @@ -2477,7 +2479,18 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->next->opcode = OP_RISCV_BNE; ins->next->sreg1 = ins->dreg; ins->next->sreg2 = RISCV_ZERO; - } else { + } else if (ins->next->opcode == OP_FBEQ) { + // rcmp rd, rs1, rs2; fbeq rd -> rceq rd, rs1, rs2; bne rd, X0 + ins->opcode = OP_RCEQ; + ins->dreg = mono_alloc_ireg (cfg); + ins->sreg1 = ins->sreg1; + ins->sreg2 = ins->sreg2; + + ins->next->opcode = OP_RISCV_BNE; + ins->next->sreg1 = ins->dreg; + ins->next->sreg2 = RISCV_ZERO; + } + else { g_print ("Unhandaled op %s following after OP_RCOMPARE\n", mono_inst_name (ins->next->opcode)); NOT_IMPLEMENTED; } From 1c07bcbb763396945c575eb69ac1332fe75bace1 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:00:06 +0800 Subject: [PATCH 043/139] OP_IMUL_OVF_UN --- src/mono/mono/mini/mini-riscv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 65d3f73e614a4..256ddef23c6a2 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1942,6 +1942,8 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LADD_OVF_UN: case OP_LSUB_OVF: case OP_IMUL_OVF: + case OP_IMUL_OVF_UN: + case OP_IMUL_OVF_UN_OOM: case OP_LMUL_OVF: case OP_LMUL_OVF_UN: case OP_LMUL_OVF_UN_OOM: From cc485c7673aed9c65327fab2d04c225a6788909a Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:01:50 +0800 Subject: [PATCH 044/139] MONO_TYPE_TYPEDBYREF --- src/mono/mono/mini/mini-riscv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 256ddef23c6a2..809dd1e5dc970 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -955,6 +955,7 @@ add_param (CallInfo *cinfo, ArgInfo *ainfo, MonoType *t) add_valuetype (cinfo, ainfo, ptype); break; case MONO_TYPE_VALUETYPE: + case MONO_TYPE_TYPEDBYREF: add_valuetype (cinfo, ainfo, ptype); break; From 99392750f8f3fdacaff62e1ed961eb865dcf50ac Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:09:35 +0800 Subject: [PATCH 045/139] float_conv_to_u4 --- src/mono/mono/mini/cpu-riscv64.mdesc | 1 + src/mono/mono/mini/mini-riscv.c | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index cd5b439384dc3..a14750c531b66 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -161,6 +161,7 @@ r4_conv_to_i8: dest:i src1:f len:4 r4_conv_to_r8: dest:f src1:f len:4 r4_conv_to_i4: dest:i src1:f len:4 float_conv_to_i4: dest:i src1:f len:4 +float_conv_to_u4: dest:i src1:f len:4 float_conv_to_r4: dest:f src1:f len:4 float_conv_to_i8: dest:i src1:f len:4 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 809dd1e5dc970..5f22d985346de 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1229,6 +1229,7 @@ mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode) return !riscv_stdext_m; case OP_FADD: + case OP_RADD: case OP_FSUB: case OP_RSUB: case OP_FDIV: @@ -1261,12 +1262,13 @@ mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode) case OP_RCONV_TO_I2: case OP_RCONV_TO_I4: case OP_ICONV_TO_R4: + case OP_FCONV_TO_I4: + case OP_FCONV_TO_R4: + case OP_FCONV_TO_U4: #ifdef TARGET_RISCV64 case OP_R8CONST: case OP_ICONV_TO_R8: case OP_LCONV_TO_R8: - case OP_FCONV_TO_I4: - case OP_FCONV_TO_R4: case OP_FCONV_TO_R8: case OP_FCONV_TO_I8: case OP_RCONV_TO_R8: @@ -1831,6 +1833,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_U2: case OP_RCONV_TO_I4: case OP_FCONV_TO_I4: + case OP_FCONV_TO_U4: case OP_ICONV_TO_R_UN: case OP_LCONV_TO_R_UN: case OP_ICONV_TO_R4: @@ -2361,6 +2364,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_RCONV_TO_I8: case OP_RCONV_TO_I4: case OP_FCONV_TO_I4: + case OP_FCONV_TO_U4: case OP_FCONV_TO_R4: case OP_FCONV_TO_I8: case OP_FCEQ: @@ -4686,6 +4690,14 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fcvt_l_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); break; } + case OP_FCONV_TO_U4:{ + g_assert (riscv_stdext_f || riscv_stdext_d); + if (riscv_stdext_d) + riscv_fcvt_wu_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + else + riscv_fcvt_wu_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + break; + } case OP_FCONV_TO_R4: case OP_RISCV_SETFREG_R4: { g_assert (riscv_stdext_d); From 47dbaca8bf3f9b18621fe3c35839fd6088e639f9 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:09:47 +0800 Subject: [PATCH 046/139] update yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 5ef097ee0500b..cd136eeac668c 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -47,7 +47,7 @@ jobs: env: ROOTFS_DIR: /crossrootfs/riscv64 QEMU_LD_PREFIX: /crossrootfs/riscv64 - CORE_ROOT: /__w/runtime/runtime/artifacts/tests/coreclr/linux.riscv64.Debug/Tests/Core_Root + CORE_ROOT: /__w/runtime/runtime/artifacts/tests/coreclr/linux.riscv64.Release/Tests/Core_Root needs: cross-build steps: - name: Checkout From eb8af5b25e326cc1884c18f3f61b2d8ae879ad32 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:14:56 +0800 Subject: [PATCH 047/139] OP_ADDCC for OP_COND_EXC_IC --- src/mono/mono/mini/mini-riscv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 5f22d985346de..b018de4efd834 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3034,7 +3034,8 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) MonoInst *branch_ins = ins->next; if (branch_ins) { - if (branch_ins->opcode == OP_COND_EXC_C || branch_ins->opcode == OP_COND_EXC_OV || branch_ins->opcode == OP_COND_EXC_IOV) { + if (branch_ins->opcode == OP_COND_EXC_C || branch_ins->opcode == OP_COND_EXC_IC || + branch_ins->opcode == OP_COND_EXC_OV || branch_ins->opcode == OP_COND_EXC_IOV) { // bne t3, t4, overflow branch_ins->opcode = OP_RISCV_EXC_BNE; branch_ins->sreg1 = mono_alloc_ireg (cfg); From 4e539faf3e6b48328d7c84a5307457cd9d18f687 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:16:14 +0800 Subject: [PATCH 048/139] OP_RCONV_TO_R4 --- src/mono/mono/mini/mini-riscv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index b018de4efd834..5c52ba6cfb5f0 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1838,6 +1838,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LCONV_TO_R_UN: case OP_ICONV_TO_R4: case OP_LCONV_TO_R4: + case OP_RCONV_TO_R4: case OP_RCONV_TO_R8: #ifdef TARGET_RISCV64 case OP_LXOR_IMM: From 431402330ad14d4fe898500e197e2644fcb7816d Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:21:52 +0800 Subject: [PATCH 049/139] fix --- src/mono/mono/mini/mini-riscv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 5c52ba6cfb5f0..90eda8e89a489 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1931,7 +1931,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LCONV_TO_OVF_I: case OP_LCONV_TO_OVF_U: case OP_LCONV_TO_OVF_I1: - case OP_LCONV_TO_OVF_I1_OVF: + case OP_LCONV_TO_OVF_I1_UN: case OP_LCONV_TO_OVF_U1: case OP_LCONV_TO_OVF_U1_UN: case OP_LCONV_TO_OVF_U2: From 8bf1094135a4d6df4dcad158ccca58e5b596f46e Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:24:30 +0800 Subject: [PATCH 050/139] update yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index cd136eeac668c..2cdb5d9e5b896 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -65,7 +65,7 @@ jobs: artifacts/tests/ key: ${{ runner.os }}-dotnet-cross-build - name: Build Tests programs - run: ./build.sh -mono -release riscv64 -tree:JIT/ --ci + run: ./build.sh -mono -Release riscv64 -tree:JIT/ --ci working-directory: ./src/tests - name: Run tests run: bash -c ./run.sh Release From ad7b6bc0bca7ec3ec866f824df75246830bc776e Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:30:27 +0800 Subject: [PATCH 051/139] OP_RCONV_TO_OVF_U8 --- src/mono/mono/mini/mini-riscv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 90eda8e89a489..8925eb2a453c0 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1868,6 +1868,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_FCONV_TO_OVF_I8: case OP_RCONV_TO_I8: case OP_RCONV_TO_OVF_I8: + case OP_RCONV_TO_OVF_U8: #endif case OP_FNEG: case OP_IAND: From b13d2d6e689705fc98a46473c256911a9867f598 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:34:57 +0800 Subject: [PATCH 052/139] lowering OP_RCONV_TO_R4 --- src/mono/mono/mini/mini-riscv.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 8925eb2a453c0..8ee2db2a85558 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1845,6 +1845,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LNEG: case OP_ICONV_TO_I4: + case OP_ICONV_TO_OVF_I4: case OP_ICONV_TO_U4: case OP_ICONV_TO_I8: case OP_ICONV_TO_U8: @@ -2449,6 +2450,13 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->sreg1 = temp->dreg; goto loop_start; } + case OP_RCONV_TO_R4: { + if (ins->dreg != ins->sreg1) + ins->opcode = OP_RMOVE; + else + NULLIFY_INS (ins); + break; + } case OP_RCOMPARE: { if (ins->next) { if (ins->next->opcode == OP_FBLT || ins->next->opcode == OP_FBLT_UN) { From 804486ae71384a5e88f0ff1db4b23b94dce6b052 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:35:49 +0800 Subject: [PATCH 053/139] OP_LCONV_TO_OVF_I2 --- src/mono/mono/mini/mini-riscv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 8ee2db2a85558..bf194e7ed4201 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1936,6 +1936,8 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LCONV_TO_OVF_I1_UN: case OP_LCONV_TO_OVF_U1: case OP_LCONV_TO_OVF_U1_UN: + case OP_LCONV_TO_OVF_I2: + case OP_LCONV_TO_OVF_I2_UN: case OP_LCONV_TO_OVF_U2: case OP_LCONV_TO_OVF_U2_UN: case OP_LCONV_TO_OVF_I4: From f9386dd01bfe9b346183ce2e239e74e386639616 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:39:19 +0800 Subject: [PATCH 054/139] OP_FCONV_TO_U1 --- src/mono/mono/mini/mini-riscv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index bf194e7ed4201..f9a1bbee38c83 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1262,6 +1262,7 @@ mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode) case OP_RCONV_TO_I2: case OP_RCONV_TO_I4: case OP_ICONV_TO_R4: + case OP_FCONV_TO_U1: case OP_FCONV_TO_I4: case OP_FCONV_TO_R4: case OP_FCONV_TO_U4: @@ -1832,6 +1833,10 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_I2: case OP_ICONV_TO_U2: case OP_RCONV_TO_I4: + case OP_FCONV_TO_I1: + case OP_FCONV_TO_U1: + case OP_FCONV_TO_I2: + case OP_FCONV_TO_U2: case OP_FCONV_TO_I4: case OP_FCONV_TO_U4: case OP_ICONV_TO_R_UN: From 9684e675b22d35581f3f1957117824cf4b32ee01 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:53:32 +0800 Subject: [PATCH 055/139] OP_LCONV_TO_OVF_I8 --- src/mono/mono/mini/mini-riscv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index f9a1bbee38c83..87b444955d960 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1867,7 +1867,6 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_R8: case OP_LCONV_TO_R8: case OP_RCONV_TO_I2: - case OP_FCONV_TO_I2: case OP_FCONV_TO_R4: case OP_FCONV_TO_R8: case OP_FCONV_TO_I8: @@ -1949,6 +1948,8 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LCONV_TO_OVF_I4_UN: case OP_LCONV_TO_OVF_U4: case OP_LCONV_TO_OVF_U4_UN: + case OP_LCONV_TO_OVF_I8: + case OP_LCONV_TO_OVF_I8_UN: case OP_LCONV_TO_OVF_U8: case OP_LCONV_TO_OVF_U8_UN: From 1ea17ed17aacf7f97fc2a73ab44c4e122012eb18 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:56:44 +0800 Subject: [PATCH 056/139] OP_RNEG --- src/mono/mono/mini/cpu-riscv64.mdesc | 1 + src/mono/mono/mini/mini-riscv.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index a14750c531b66..3eb857fbb1f9b 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -149,6 +149,7 @@ float_mul: dest:f src1:f src2:f len:4 float_div: dest:f src1:f src2:f len:36 r4const: dest:f len:16 +r4_neg: dest:f src1:f len:4 r4_add: dest:f src1:f src2:f len:4 r4_sub: dest:f src1:f src2:f len:4 r4_mul: dest:f src1:f src2:f len:4 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 87b444955d960..356ab4e44f043 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1236,6 +1236,7 @@ mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode) case OP_RDIV: case OP_FMUL: case OP_RMUL: + case OP_RNEG: case OP_FNEG: case OP_FMOVE: case OP_RMOVE: @@ -1875,6 +1876,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_RCONV_TO_OVF_I8: case OP_RCONV_TO_OVF_U8: #endif + case OP_RNEG: case OP_FNEG: case OP_IAND: case OP_IAND_IMM: @@ -2369,6 +2371,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_R8CONST: case OP_RADD: case OP_FADD: + case OP_RNEG: case OP_FNEG: case OP_ICONV_TO_R8: case OP_RCONV_TO_R8: @@ -4355,6 +4358,10 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) g_assert (riscv_stdext_f); riscv_fsub_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); break; + case OP_RNEG: + g_assert (riscv_stdext_f); + riscv_fsgnjn_s (code, ins->dreg, ins->sreg1, ins->sreg1); + break; case OP_FNEG: g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) From 6b69bc08184cff153291e6a56b34ae43c1d8320f Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 17:59:27 +0800 Subject: [PATCH 057/139] OP_LSHR --- src/mono/mono/mini/cpu-riscv64.mdesc | 1 + src/mono/mono/mini/mini-riscv.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 3eb857fbb1f9b..a237b2fa96e1d 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -205,6 +205,7 @@ long_xor: dest:i src1:i src2:i len:4 long_or_imm: dest:i src1:i len:4 long_shl: dest:i src1:i src2:i len:4 long_shl_imm: dest:i src1:i len:4 +long_shr: dest:i src1:i src2:i len:4 long_shr_un: dest:i src1:i src2:i len:4 long_shr_imm: dest:i src1:i len:4 long_shr_un_imm: dest:i src1:i len:4 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 356ab4e44f043..0650f5f093bf6 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1892,6 +1892,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ISHL_IMM: case OP_LSHL_IMM: case OP_ISHR: + case OP_LSHR: case OP_ISHR_UN: case OP_LSHR_UN: case OP_ISHR_IMM: @@ -2319,6 +2320,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_ISHR_IMM: case OP_SHR_UN_IMM: case OP_ISHR_UN_IMM: + case OP_LSHR: case OP_LSHR_UN: case OP_LSHR_IMM: case OP_LSHR_UN_IMM: From c3bb8151cd52ec03bdfe068b928799a5a727512c Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 18:35:42 +0800 Subject: [PATCH 058/139] OP_{F|R}CONV_TO_U* --- src/mono/mono/mini/mini-riscv.c | 90 +++++++++++++++++++++++++++++---- 1 file changed, 80 insertions(+), 10 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 0650f5f093bf6..3dc391f9f6b69 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1263,7 +1263,10 @@ mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode) case OP_RCONV_TO_I2: case OP_RCONV_TO_I4: case OP_ICONV_TO_R4: + case OP_FCONV_TO_I1: case OP_FCONV_TO_U1: + case OP_FCONV_TO_I2: + case OP_FCONV_TO_U2: case OP_FCONV_TO_I4: case OP_FCONV_TO_R4: case OP_FCONV_TO_U4: @@ -2438,30 +2441,97 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->sreg2 = tmp_reg; break; } + case OP_FCONV_TO_I1: + case OP_RCONV_TO_I1:{ + // fconv_to_i1 rd, fs1 => fconv_to_i{4|8} rs1, fs1; {i|l}conv_to_i1 rd, rs1 + int rd = ins->dreg; +#ifdef TARGET_RISCV64 + NEW_INS_AFTER (cfg, ins, temp, OP_LCONV_TO_I1); + if (ins->opcode == OP_FCONV_TO_I1) + ins->opcode = OP_FCONV_TO_I8; + else + ins->opcode = OP_RCONV_TO_I8; +#else + NEW_INS_AFTER (cfg, ins, temp, OP_ICONV_TO_I1); + if (ins->opcode == OP_FCONV_TO_I1) + ins->opcode = OP_FCONV_TO_I4; + else + ins->opcode = OP_RCONV_TO_I4; +#endif + ins->dreg = mono_alloc_ireg (cfg); + + temp->dreg = rd; + temp->sreg1 = ins->dreg; + break; + } + case OP_FCONV_TO_U1: + case OP_RCONV_TO_U1: { + // fconv_to_u1 rd, fs1 => fconv_to_u{4|8} rs1, fs1; {i|l}conv_to_u1 rd, rs1 + int rd = ins->dreg; +#ifdef TARGET_RISCV64 + NEW_INS_AFTER (cfg, ins, temp, OP_LCONV_TO_U1); + if (ins->opcode == OP_FCONV_TO_U1) + ins->opcode = OP_FCONV_TO_U8; + else + ins->opcode = OP_RCONV_TO_U8; +#else + NEW_INS_AFTER (cfg, ins, temp, OP_ICONV_TO_U1); + if (ins->opcode == OP_FCONV_TO_U1) + ins->opcode = OP_FCONV_TO_U4; + else + ins->opcode = OP_RCONV_TO_U4; +#endif + ins->dreg = mono_alloc_ireg (cfg); + + temp->dreg = rd; + temp->sreg1 = ins->dreg; + break; + } case OP_FCONV_TO_I2: case OP_RCONV_TO_I2: { // fconv_to_i2 rd, fs1 => fconv_to_i{4|8} rs1, fs1; {i|l}conv_to_i2 rd, rs1 + int rd = ins->dreg; #ifdef TARGET_RISCV64 + NEW_INS_AFTER (cfg, ins, temp, OP_LCONV_TO_I2); if (ins->opcode == OP_FCONV_TO_I2) - NEW_INS_BEFORE (cfg, ins, temp, OP_FCONV_TO_I8); + ins->opcode = OP_FCONV_TO_I8; else - NEW_INS_BEFORE (cfg, ins, temp, OP_RCONV_TO_I8); + ins->opcode = OP_RCONV_TO_I8; #else + NEW_INS_AFTER (cfg, ins, temp, OP_ICONV_TO_I2); if (ins->opcode == OP_FCONV_TO_I2) - NEW_INS_BEFORE (cfg, ins, temp, OP_FCONV_TO_I4); + ins->opcode = OP_FCONV_TO_I4; else - NEW_INS_BEFORE (cfg, ins, temp, OP_RCONV_TO_I4); + ins->opcode = OP_RCONV_TO_I4; #endif - temp->dreg = mono_alloc_ireg (cfg); - temp->sreg1 = ins->sreg1; + ins->dreg = mono_alloc_ireg (cfg); + temp->dreg = rd; + temp->sreg1 = ins->dreg; + break; + } + case OP_FCONV_TO_U2: + case OP_RCONV_TO_U2: { + // fconv_to_u2 rd, fs1 => fconv_to_u{4|8} rs1, fs1; {i|l}conv_to_u2 rd, rs1 + int rd = ins->dreg; #ifdef TARGET_RISCV64 - ins->opcode = OP_LCONV_TO_I2; + NEW_INS_AFTER (cfg, ins, temp, OP_LCONV_TO_U2); + if (ins->opcode == OP_FCONV_TO_U2) + ins->opcode = OP_FCONV_TO_U8; + else + ins->opcode = OP_RCONV_TO_U8; #else - ins->opcode = OP_ICONV_TO_I2; + NEW_INS_AFTER (cfg, ins, temp, OP_ICONV_TO_U2); + if (ins->opcode == OP_FCONV_TO_U2) + ins->opcode = OP_FCONV_TO_U4; + else + ins->opcode = OP_RCONV_TO_U4; #endif - ins->sreg1 = temp->dreg; - goto loop_start; + ins->dreg = mono_alloc_ireg (cfg); + + temp->dreg = rd; + temp->sreg1 = ins->dreg; + break; } case OP_RCONV_TO_R4: { if (ins->dreg != ins->sreg1) From 731f788852afb70a2a973bceae5aab7e1ba4f500 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 19:22:57 +0800 Subject: [PATCH 059/139] OP_CKFINITE --- src/mono/mono/mini/cpu-riscv64.mdesc | 1 + src/mono/mono/mini/mini-riscv.c | 13 +++++++++++++ src/mono/mono/mini/mini-riscv.h | 3 +++ 3 files changed, 17 insertions(+) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index a237b2fa96e1d..7647cf119d5b2 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -45,6 +45,7 @@ endfilter: src1:i len:32 localloc: dest:i src1:i len:52 localloc_imm: dest:i len:28 generic_class_init: src1:a len:12 clob:c +ckfinite: dest:f src1:f len:24 break: len:4 throw: src1:i len:4 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 3dc391f9f6b69..54729754e3e12 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1810,6 +1810,7 @@ void mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) { switch (ins->opcode) { + case OP_CKFINITE: case OP_LADD: case OP_LADD_IMM: case OP_IADD: @@ -2250,6 +2251,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) { loop_start: switch (ins->opcode) { + case OP_CKFINITE: case OP_BREAK: case OP_IL_SEQ_POINT: case OP_SEQ_POINT: @@ -4286,6 +4288,17 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) mono_riscv_patch (branch_label, code, MONO_R_RISCV_BNE); break; } + case OP_CKFINITE: { + g_assert (riscv_stdext_d || riscv_stdext_f); + /* Check for infinity and nans */ + if (riscv_stdext_d) + riscv_fclass_d (code, RISCV_T0, ins->sreg1); + else + riscv_fclass_s (code, RISCV_T0, ins->sreg1); + riscv_andi (code, RISCV_T0, RISCV_T0, 0b0001111110); + code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BEQ, RISCV_T0, RISCV_ZERO, + "ArithmeticException"); + } case OP_BREAK: /* * gdb does not like encountering the hw breakpoint ins in the debugged code. diff --git a/src/mono/mono/mini/mini-riscv.h b/src/mono/mono/mini/mini-riscv.h index 8cef6420e3438..57ec36ea0e3e1 100644 --- a/src/mono/mono/mini/mini-riscv.h +++ b/src/mono/mono/mini/mini-riscv.h @@ -296,6 +296,9 @@ mono_riscv_throw_exception (gpointer arg, host_mgreg_t pc, host_mgreg_t *int_reg __attribute__ ((warn_unused_result)) guint8 * mono_riscv_emit_imm (guint8 *code, int rd, gsize imm); +__attribute__ ((warn_unused_result)) guint8 * +mono_riscv_emit_float_imm (guint8 *code, int rd, gsize f_imm, gboolean isSingle); + __attribute__ ((warn_unused_result)) guint8 *mono_riscv_emit_float_imm (guint8 *code, int rd, gsize f_imm, From 57606b307d289ce7288e348c1bbab11dc1c99c35 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 19:23:57 +0800 Subject: [PATCH 060/139] update yml --- .github/workflows/jit-riscv64.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 2cdb5d9e5b896..d3bead1910fac 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -47,7 +47,7 @@ jobs: env: ROOTFS_DIR: /crossrootfs/riscv64 QEMU_LD_PREFIX: /crossrootfs/riscv64 - CORE_ROOT: /__w/runtime/runtime/artifacts/tests/coreclr/linux.riscv64.Release/Tests/Core_Root + CORE_ROOT: /__w/runtime/runtime/artifacts/tests/coreclr/linux.riscv64.Debug/Tests/Core_Root needs: cross-build steps: - name: Checkout @@ -65,9 +65,9 @@ jobs: artifacts/tests/ key: ${{ runner.os }}-dotnet-cross-build - name: Build Tests programs - run: ./build.sh -mono -Release riscv64 -tree:JIT/ --ci + run: ./build.sh -mono -Debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests - name: Run tests - run: bash -c ./run.sh Release + run: bash -c ./run.sh Debug working-directory: ./src/tests From 6a67ad4ffd6e0dc12f61ad860ebfcb81ad65776e Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 19:25:49 +0800 Subject: [PATCH 061/139] update yml --- .github/workflows/jit-riscv64.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index d3bead1910fac..d847a38eb48e2 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -24,11 +24,12 @@ jobs: artifacts/ key: ${{ runner.os }}-dotnet-cross-build + - name: Cross Build Libs & host + run: ./build.sh libs -c Release --cross --arch riscv64 --ci + - name: Cross Build Mono # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build - run: ./build.sh mono -c Debug --cross --arch riscv64 --ci - - name: Cross Build Libs & host - run: ./build.sh mono+libs+host+clr.hosts -c Release --cross --arch riscv64 --ci + run: ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ci - name: compress files run: tar -zcf runtime.tar.gz ./.dotnet ./artifacts From 2cddc57df422b3a8d688a42c65bdc64a1dc3a326 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 19:28:26 +0800 Subject: [PATCH 062/139] OP_FCONV_TO_U8 --- src/mono/mono/mini/cpu-riscv64.mdesc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 7647cf119d5b2..7dfc5ff49adc2 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -166,6 +166,7 @@ float_conv_to_i4: dest:i src1:f len:4 float_conv_to_u4: dest:i src1:f len:4 float_conv_to_r4: dest:f src1:f len:4 float_conv_to_i8: dest:i src1:f len:4 +float_conv_to_u8: dest:i src1:f len:4 r4_ceq: dest:i src1:f src2:f len:4 r4_clt: dest:i src1:f src2:f len:4 From e966be838817b1ecb94f40cb8082f94040a94c2d Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 19:31:42 +0800 Subject: [PATCH 063/139] rcall_reg --- src/mono/mono/mini/cpu-riscv64.mdesc | 5 +++-- src/mono/mono/mini/mini-riscv.c | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 7dfc5ff49adc2..d4c8073e17d8c 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -64,10 +64,11 @@ vcall2: len:16 clob:c vcall2_reg: src1:i len:16 clob:c vcall2_membase: src1:b len:28 clob:c fcall: dest:f len:8 clob:c -rcall: dest:f len:8 clob:c -rcall_membase: dest:f src1:b len:12 clob:c fcall_reg: dest:f src1:i len:8 clob:c fcall_membase: dest:f src1:b len:12 clob:c +rcall: dest:f len:8 clob:c +rcall_reg: dest:f src1:i len:8 clob:c +rcall_membase: dest:f src1:b len:12 clob:c # Note: in RV32, it shoule be # lcall: dest:l ... diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 54729754e3e12..5b6edb790d4b4 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2701,6 +2701,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) break; case OP_CALL_REG: case OP_LCALL_REG: + case OP_RCALL_REG: case OP_FCALL_REG: case OP_VOIDCALL_REG: case OP_VCALL2_REG: @@ -4978,6 +4979,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_CALL: case OP_RCALL: case OP_FCALL: + case OP_RCALL: case OP_LCALL: case OP_VCALL2: { call = (MonoCallInst *)ins; From dba4f450ff9f19beea27530d38ca159f6f8d00fe Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 19:33:34 +0800 Subject: [PATCH 064/139] remove assert of OP_TAILCALL --- src/mono/mono/mini/mini-riscv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 5b6edb790d4b4..a410d4fc80122 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -4941,8 +4941,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) g_assert_not_reached (); } - g_assert(call->stack_usage == 0); - /* Restore registers */ code = mono_riscv_emit_load_stack (code, MONO_ARCH_CALLEE_SAVED_REGS & cfg->used_int_regs, RISCV_FP, -cfg->arch.saved_gregs_offset, FALSE); From 68df0b3b0796cdf6f36c9746075b9e4130205c48 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 19:34:27 +0800 Subject: [PATCH 065/139] OP_ICONV_TO_OVF_I --- src/mono/mono/mini/mini-riscv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index a410d4fc80122..f59c2e0de06b8 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1925,6 +1925,8 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LREM_UN: case OP_IREM_UN_IMM: + case OP_ICONV_TO_OVF_I: + case OP_ICONV_TO_OVF_U: case OP_ICONV_TO_OVF_I1: case OP_ICONV_TO_OVF_I1_UN: case OP_ICONV_TO_OVF_U1: From e84db51c6cb1470506eb915b3b7e0d3fd38040eb Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 19:40:47 +0800 Subject: [PATCH 066/139] OP_LSUB_OVF_UN --- src/mono/mono/mini/mini-riscv.c | 34 +++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index f59c2e0de06b8..90e8f414b8ae5 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1811,14 +1811,16 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) { switch (ins->opcode) { case OP_CKFINITE: - case OP_LADD: - case OP_LADD_IMM: case OP_IADD: + case OP_LADD: + case OP_RADD: + case OP_FADD: case OP_IADD_IMM: + case OP_LADD_IMM: case OP_IADD_OVF: + case OP_LADD_OVF: + case OP_LADD_OVF_UN: case OP_IADD_OVF_UN: - case OP_RADD: - case OP_FADD: case OP_ISUB: case OP_LSUB: case OP_FSUB: @@ -1826,6 +1828,10 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ISUB_IMM: case OP_LSUB_IMM: case OP_ISUB_OVF: + case OP_LSUB_OVF: + case OP_ISUB_OVF_UN: + case OP_LSUB_OVF_UN: + case OP_INEG: case OP_LAND: case OP_LOR: @@ -1910,10 +1916,17 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_FMUL: case OP_IMUL_IMM: case OP_LMUL_IMM: + case OP_IMUL_OVF: + case OP_LMUL_OVF: + case OP_IMUL_OVF_UN: + case OP_LMUL_OVF_UN: + case OP_IMUL_OVF_UN_OOM: + case OP_LMUL_OVF_UN_OOM: case OP_IDIV: case OP_LDIV: - case OP_LDIV_UN: + case OP_FDIV: case OP_IDIV_UN: + case OP_LDIV_UN: case OP_IDIV_IMM: case OP_IDIV_UN_IMM: case OP_RDIV: @@ -1962,17 +1975,6 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LCONV_TO_OVF_U8: case OP_LCONV_TO_OVF_U8_UN: - case OP_LADD_OVF: - case OP_LADD_OVF_UN: - case OP_LSUB_OVF: - case OP_IMUL_OVF: - case OP_IMUL_OVF_UN: - case OP_IMUL_OVF_UN_OOM: - case OP_LMUL_OVF: - case OP_LMUL_OVF_UN: - case OP_LMUL_OVF_UN_OOM: - - case OP_FDIV: break; default: g_print ("Can't decompose the OP %s\n", mono_inst_name (ins->opcode)); From 893ec6aa32d1dfd40bd72187e46a7d72e77139fa Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 19:46:32 +0800 Subject: [PATCH 067/139] OP_FBNE_UN after OP_RCOMPARE --- src/mono/mono/mini/mini-riscv.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 90e8f414b8ae5..d59486327725b 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2588,14 +2588,18 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) } else if (ins->next->opcode == OP_FBEQ) { // rcmp rd, rs1, rs2; fbeq rd -> rceq rd, rs1, rs2; bne rd, X0 ins->opcode = OP_RCEQ; - ins->dreg = mono_alloc_ireg (cfg); - ins->sreg1 = ins->sreg1; - ins->sreg2 = ins->sreg2; ins->next->opcode = OP_RISCV_BNE; ins->next->sreg1 = ins->dreg; ins->next->sreg2 = RISCV_ZERO; - } + } else if (ins->next->opcode == OP_FBNE_UN) { + // rcmp rd, rs1, rs2; fbne rd -> rceq rd, rs1, rs2; beq rd, X0 + ins->opcode = OP_RCEQ; + + ins->next->opcode = OP_RISCV_BEQ; + ins->next->sreg1 = ins->dreg; + ins->next->sreg2 = RISCV_ZERO; + } else { g_print ("Unhandaled op %s following after OP_RCOMPARE\n", mono_inst_name (ins->next->opcode)); NOT_IMPLEMENTED; From 5e285d92e03b4187e5896056c06632c42fa801cb Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 20:59:19 +0800 Subject: [PATCH 068/139] fix --- src/mono/mono/mini/mini-riscv.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index d59486327725b..3a1f93bce823d 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -4983,7 +4983,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) } case OP_VOIDCALL: case OP_CALL: - case OP_RCALL: case OP_FCALL: case OP_RCALL: case OP_LCALL: From 5895c22901600e53dac8dbc29edc6e4f6f617866 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 20:59:25 +0800 Subject: [PATCH 069/139] update ymal --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index d847a38eb48e2..59a530a05584c 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -41,7 +41,6 @@ jobs: path: ./runtime.tar.gz test: - continue-on-error: true runs-on: ubuntu-latest container: image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-riscv64 @@ -69,6 +68,7 @@ jobs: run: ./build.sh -mono -Debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests - name: Run tests + continue-on-error: true run: bash -c ./run.sh Debug working-directory: ./src/tests From 9b626a1214e13445fce84628cda9c9bb2f198acb Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 21:01:49 +0800 Subject: [PATCH 070/139] fix rd for lowering OP_RCOMPARE --- src/mono/mono/mini/mini-riscv.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 3a1f93bce823d..9b2353e917142 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2586,15 +2586,17 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->next->sreg1 = ins->dreg; ins->next->sreg2 = RISCV_ZERO; } else if (ins->next->opcode == OP_FBEQ) { - // rcmp rd, rs1, rs2; fbeq rd -> rceq rd, rs1, rs2; bne rd, X0 + // rcmp rs1, rs2; fbeq rd -> rceq rd, rs1, rs2; bne rd, X0 ins->opcode = OP_RCEQ; + ins->dreg = mono_alloc_ireg (cfg); ins->next->opcode = OP_RISCV_BNE; ins->next->sreg1 = ins->dreg; ins->next->sreg2 = RISCV_ZERO; } else if (ins->next->opcode == OP_FBNE_UN) { - // rcmp rd, rs1, rs2; fbne rd -> rceq rd, rs1, rs2; beq rd, X0 + // rcmp rs1, rs2; fbne rd -> rceq rd, rs1, rs2; beq rd, X0 ins->opcode = OP_RCEQ; + ins->dreg = mono_alloc_ireg (cfg); ins->next->opcode = OP_RISCV_BEQ; ins->next->sreg1 = ins->dreg; From 6308c48f1a95f114f0239ae694e4e650769d56fc Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 21:18:19 +0800 Subject: [PATCH 071/139] decompose the OP long_conv_to_i1 --- src/mono/mono/mini/mini-riscv.c | 38 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 9b2353e917142..ec1524ce2a208 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1867,6 +1867,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_U8: case OP_LCONV_TO_U: case OP_LCONV_TO_I: + case OP_LCONV_TO_I1: case OP_LCONV_TO_U1: case OP_LCONV_TO_I2: case OP_LCONV_TO_U2: @@ -1874,6 +1875,25 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LCONV_TO_U4: case OP_LCONV_TO_I8: case OP_LCONV_TO_U8: + + case OP_LCONV_TO_OVF_I: + case OP_LCONV_TO_OVF_U: + case OP_LCONV_TO_OVF_I1: + case OP_LCONV_TO_OVF_I1_UN: + case OP_LCONV_TO_OVF_U1: + case OP_LCONV_TO_OVF_U1_UN: + case OP_LCONV_TO_OVF_I2: + case OP_LCONV_TO_OVF_I2_UN: + case OP_LCONV_TO_OVF_U2: + case OP_LCONV_TO_OVF_U2_UN: + case OP_LCONV_TO_OVF_I4: + case OP_LCONV_TO_OVF_I4_UN: + case OP_LCONV_TO_OVF_U4: + case OP_LCONV_TO_OVF_U4_UN: + case OP_LCONV_TO_OVF_I8: + case OP_LCONV_TO_OVF_I8_UN: + case OP_LCONV_TO_OVF_U8: + case OP_LCONV_TO_OVF_U8_UN: case OP_ICONV_TO_R8: case OP_LCONV_TO_R8: @@ -1956,24 +1976,6 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_OVF_U8_UN: case OP_ICONV_TO_OVF_I_UN: case OP_ICONV_TO_OVF_U_UN: - case OP_LCONV_TO_OVF_I: - case OP_LCONV_TO_OVF_U: - case OP_LCONV_TO_OVF_I1: - case OP_LCONV_TO_OVF_I1_UN: - case OP_LCONV_TO_OVF_U1: - case OP_LCONV_TO_OVF_U1_UN: - case OP_LCONV_TO_OVF_I2: - case OP_LCONV_TO_OVF_I2_UN: - case OP_LCONV_TO_OVF_U2: - case OP_LCONV_TO_OVF_U2_UN: - case OP_LCONV_TO_OVF_I4: - case OP_LCONV_TO_OVF_I4_UN: - case OP_LCONV_TO_OVF_U4: - case OP_LCONV_TO_OVF_U4_UN: - case OP_LCONV_TO_OVF_I8: - case OP_LCONV_TO_OVF_I8_UN: - case OP_LCONV_TO_OVF_U8: - case OP_LCONV_TO_OVF_U8_UN: break; default: From 980b4537935d48584ee95aaa8fb35db63a7554c2 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 22:47:34 +0800 Subject: [PATCH 072/139] update yml --- .github/workflows/jit-riscv64.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 59a530a05584c..1a9ebc92e8af1 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -71,4 +71,10 @@ jobs: continue-on-error: true run: bash -c ./run.sh Debug working-directory: ./src/tests + - name: Upload Test error Log + if: ${{ failure() }} + uses: actions/upload-artifact@v2 + with: + name: test-error-log.log + path: ./artifacts/log/TestRunResults_linux_riscv64_Debug.log From 2f1e7a37871be54ff5d9c4f25a90def2e4bbf031 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 22:53:59 +0800 Subject: [PATCH 073/139] tailcall_reg --- src/mono/mono/mini/cpu-riscv64.mdesc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index d4c8073e17d8c..bd94166c1fed8 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -77,9 +77,9 @@ lcall_reg: dest:a src1:i len:4 clob:c lcall_membase: dest:a src1:b len:8 clob:c tailcall_parameter: len:24 -tailcall: len:24 clob:c -tailcall_membase: src1:b len:24 clob:c -tailcall_reg: src1:b len:24 clob:c +tailcall: len:60 clob:c +tailcall_membase: src1:b len:60 clob:c +tailcall_reg: src1:b len:60 clob:c store_membase_reg: dest:b src1:i len:24 storei1_membase_reg: dest:b src1:i len:24 From 4c1f60cc9e4a324a7803b1459257c563843145ef Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 22:54:31 +0800 Subject: [PATCH 074/139] r4_conv_to_u4 --- src/mono/mono/mini/cpu-riscv64.mdesc | 1 + src/mono/mono/mini/mini-riscv.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index bd94166c1fed8..954fc5bf9fa16 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -163,6 +163,7 @@ int_conv_to_r8: dest:f src1:i len:4 r4_conv_to_i8: dest:i src1:f len:4 r4_conv_to_r8: dest:f src1:f len:4 r4_conv_to_i4: dest:i src1:f len:4 +r4_conv_to_u4: dest:i src1:f len:4 float_conv_to_i4: dest:i src1:f len:4 float_conv_to_u4: dest:i src1:f len:4 float_conv_to_r4: dest:f src1:f len:4 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index ec1524ce2a208..051e525cb6670 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1262,6 +1262,7 @@ mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode) case OP_FBGT_UN: case OP_RCONV_TO_I2: case OP_RCONV_TO_I4: + case OP_RCONV_TO_U4: case OP_ICONV_TO_R4: case OP_FCONV_TO_I1: case OP_FCONV_TO_U1: @@ -1844,6 +1845,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_I2: case OP_ICONV_TO_U2: case OP_RCONV_TO_I4: + case OP_RCONV_TO_U4: case OP_FCONV_TO_I1: case OP_FCONV_TO_U1: case OP_FCONV_TO_I2: @@ -2390,6 +2392,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_RCONV_TO_R8: case OP_RCONV_TO_I8: case OP_RCONV_TO_I4: + case OP_RCONV_TO_U4: case OP_FCONV_TO_I4: case OP_FCONV_TO_U4: case OP_FCONV_TO_R4: @@ -4798,6 +4801,11 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fcvt_w_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); break; } + case OP_RCONV_TO_U4: { + g_assert (riscv_stdext_f); + riscv_fcvt_wu_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + break; + } case OP_FCONV_TO_I4: { g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) From 11210020c05d311adbc135f528ad0b516b24fde1 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 22:57:22 +0800 Subject: [PATCH 075/139] process OP_COND_EXC_NC after OP_LSUBCC --- src/mono/mono/mini/mini-riscv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 051e525cb6670..b06891b10905c 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3096,7 +3096,8 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->opcode = OP_ISUB; MonoInst *branch_ins = ins->next; if (branch_ins) { - if (branch_ins->opcode == OP_COND_EXC_OV || ins->next->opcode == OP_COND_EXC_IOV) { + if (branch_ins->opcode == OP_COND_EXC_OV || ins->next->opcode == OP_COND_EXC_IOV || + branch_ins->opcode == OP_COND_EXC_NC) { // bne t1, t2, overflow branch_ins->opcode = OP_RISCV_EXC_BNE; branch_ins->sreg1 = mono_alloc_ireg (cfg); From 87c897db86e2e610cd742ac543452923c8fefc8e Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 23:42:54 +0800 Subject: [PATCH 076/139] update yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 1a9ebc92e8af1..d6f3f11e14eda 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -41,6 +41,7 @@ jobs: path: ./runtime.tar.gz test: + continue-on-error: true runs-on: ubuntu-latest container: image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-riscv64 @@ -68,7 +69,6 @@ jobs: run: ./build.sh -mono -Debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests - name: Run tests - continue-on-error: true run: bash -c ./run.sh Debug working-directory: ./src/tests - name: Upload Test error Log From 382db7e733783f15c1984365f43576b3280e7c54 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 23:55:33 +0800 Subject: [PATCH 077/139] OP_FCONV_TO_U8 --- src/mono/mono/mini/mini-riscv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index b06891b10905c..b0b774472108d 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1277,6 +1277,7 @@ mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode) case OP_LCONV_TO_R8: case OP_FCONV_TO_R8: case OP_FCONV_TO_I8: + case OP_FCONV_TO_U8: case OP_RCONV_TO_R8: #endif return !mono_arch_is_soft_float (); From 1a535470f628eeb0d723177accb966c8280667ea Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 19 Dec 2023 23:56:50 +0800 Subject: [PATCH 078/139] OP_ICONV_TO_OVF_I4_UN --- src/mono/mono/mini/mini-riscv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index b0b774472108d..a71ea991417ea 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1865,6 +1865,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_I4: case OP_ICONV_TO_OVF_I4: + case OP_ICONV_TO_OVF_I4_UN: case OP_ICONV_TO_U4: case OP_ICONV_TO_I8: case OP_ICONV_TO_U8: From 3ada136529b60bd47d5b2134936bcb513a1da9c0 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 00:07:16 +0800 Subject: [PATCH 079/139] OP_FREM --- src/mono/mono/mini/mini-riscv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index a71ea991417ea..b711d29a964a0 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1956,6 +1956,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_RDIV: case OP_IREM: case OP_LREM: + case OP_FREM: case OP_IREM_IMM: case OP_LREM_IMM: case OP_IREM_UN: From 4f9ba893b7f264865048470de36f7ee40c3e90ad Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 00:09:04 +0800 Subject: [PATCH 080/139] OP_RREM --- src/mono/mono/mini/mini-riscv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index b711d29a964a0..320142bd9af9a 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1957,6 +1957,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_IREM: case OP_LREM: case OP_FREM: + case OP_RREM: case OP_IREM_IMM: case OP_LREM_IMM: case OP_IREM_UN: From 51dd55038ff45bcb9f0a8337f92fa71b8d650d52 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 00:19:03 +0800 Subject: [PATCH 081/139] OP_FCONV_TO_U8, OP_FCONV_TO_OVF_U8 --- src/mono/mono/mini/mini-riscv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 320142bd9af9a..7d5e7c430eeaa 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1278,6 +1278,7 @@ mono_arch_opcode_needs_emulation (MonoCompile *cfg, int opcode) case OP_FCONV_TO_R8: case OP_FCONV_TO_I8: case OP_FCONV_TO_U8: + case OP_FCONV_TO_OVF_U8: case OP_RCONV_TO_R8: #endif return !mono_arch_is_soft_float (); @@ -1905,7 +1906,9 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_FCONV_TO_R4: case OP_FCONV_TO_R8: case OP_FCONV_TO_I8: + case OP_FCONV_TO_U8: case OP_FCONV_TO_OVF_I8: + case OP_FCONV_TO_OVF_U8: case OP_RCONV_TO_I8: case OP_RCONV_TO_OVF_I8: case OP_RCONV_TO_OVF_U8: From 80ab57fd2ac901860063f0def67a17e91ddd8aaa Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 12:18:38 +0800 Subject: [PATCH 082/139] update test Script --- .github/workflows/jit-riscv64.yml | 4 +++- src/tests/run.py | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index d6f3f11e14eda..c73fab731d183 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -49,6 +49,8 @@ jobs: ROOTFS_DIR: /crossrootfs/riscv64 QEMU_LD_PREFIX: /crossrootfs/riscv64 CORE_ROOT: /__w/runtime/runtime/artifacts/tests/coreclr/linux.riscv64.Debug/Tests/Core_Root + # set timeout to 5 minutes + __TestTimeout: ${{5*60*1000}}} needs: cross-build steps: - name: Checkout @@ -69,7 +71,7 @@ jobs: run: ./build.sh -mono -Debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests - name: Run tests - run: bash -c ./run.sh Debug + run: /crossrootfs/riscv64/bin/qemu-riscv64-static /crossrootfs/riscv64/bin/bash -c ./run.sh Debug --test-env=/home/wuxinlong/workspace/runtime/src/tests/setTestEnv.sh working-directory: ./src/tests - name: Upload Test error Log if: ${{ failure() }} diff --git a/src/tests/run.py b/src/tests/run.py index 5f2a90c4468ab..7d284c610b62d 100755 --- a/src/tests/run.py +++ b/src/tests/run.py @@ -805,8 +805,8 @@ def run_tests(args, test_env_script_path : Path to script to use to set the test environment, if any. """ - # Set default per-test timeout to 30 minutes (in milliseconds). - per_test_timeout = 30*60*1000 + # Set default per-test timeout to 5 minutes (in milliseconds). + per_test_timeout = 5*60*1000 # Setup the environment if args.long_gc: @@ -862,8 +862,11 @@ def run_tests(args, # Set __TestTimeout environment variable, which is the per-test timeout in milliseconds. # This is read by the test wrapper invoker, in src\tests\Common\Coreclr.TestWrapper\CoreclrTestWrapperLib.cs. - print("Setting __TestTimeout=%s" % str(per_test_timeout)) - os.environ["__TestTimeout"] = str(per_test_timeout) + if "__TestTimeout" in os.environ: + print("__TestTimeout already set in environment to %s" % os.environ["__TestTimeout"]) + else: + print("Setting __TestTimeout=%s" % str(per_test_timeout)) + os.environ["__TestTimeout"] = str(per_test_timeout) # Set CORE_ROOT print("Setting CORE_ROOT=%s" % args.core_root) From f84a699c8c199f4d175c98a813f13a55ada73b97 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Wed, 20 Dec 2023 12:21:22 +0800 Subject: [PATCH 083/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index c73fab731d183..2de0b083829a4 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -50,7 +50,7 @@ jobs: QEMU_LD_PREFIX: /crossrootfs/riscv64 CORE_ROOT: /__w/runtime/runtime/artifacts/tests/coreclr/linux.riscv64.Debug/Tests/Core_Root # set timeout to 5 minutes - __TestTimeout: ${{5*60*1000}}} + __TestTimeout: ${{ 5*60*1000 }} needs: cross-build steps: - name: Checkout From aa4e8e8df86913bbe634c61d1626fc234db00e7b Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Wed, 20 Dec 2023 12:21:54 +0800 Subject: [PATCH 084/139] Update jit-riscv64.yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 2de0b083829a4..8da9945f11cd5 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -50,7 +50,7 @@ jobs: QEMU_LD_PREFIX: /crossrootfs/riscv64 CORE_ROOT: /__w/runtime/runtime/artifacts/tests/coreclr/linux.riscv64.Debug/Tests/Core_Root # set timeout to 5 minutes - __TestTimeout: ${{ 5*60*1000 }} + __TestTimeout: 300000 needs: cross-build steps: - name: Checkout From f9cd851ec0e76bac6b930db6ba13f26ef6bb4244 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 12:24:53 +0800 Subject: [PATCH 085/139] update test Script --- src/tests/run.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/run.py b/src/tests/run.py index 7d284c610b62d..9c30ded6a1678 100755 --- a/src/tests/run.py +++ b/src/tests/run.py @@ -805,8 +805,8 @@ def run_tests(args, test_env_script_path : Path to script to use to set the test environment, if any. """ - # Set default per-test timeout to 5 minutes (in milliseconds). - per_test_timeout = 5*60*1000 + # Set default per-test timeout to 2 minutes (in milliseconds). + per_test_timeout = 2*60*1000 # Setup the environment if args.long_gc: From ea5574d7af8a80ab3772d75418b171c3d408dd00 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 12:32:22 +0800 Subject: [PATCH 086/139] clean yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index c73fab731d183..9c13f56bbdf54 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -71,7 +71,7 @@ jobs: run: ./build.sh -mono -Debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests - name: Run tests - run: /crossrootfs/riscv64/bin/qemu-riscv64-static /crossrootfs/riscv64/bin/bash -c ./run.sh Debug --test-env=/home/wuxinlong/workspace/runtime/src/tests/setTestEnv.sh + run: /crossrootfs/riscv64/bin/qemu-riscv64-static /crossrootfs/riscv64/bin/bash -c ./run.sh Debug working-directory: ./src/tests - name: Upload Test error Log if: ${{ failure() }} From 5c63d94d8bd4c921d16eaee2090df9a0b292378e Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 13:43:22 +0800 Subject: [PATCH 087/139] update yml --- .github/workflows/jit-riscv64.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml index 87ad7e0c4a26b..22318010a68ad 100644 --- a/.github/workflows/jit-riscv64.yml +++ b/.github/workflows/jit-riscv64.yml @@ -71,7 +71,7 @@ jobs: run: ./build.sh -mono -Debug riscv64 -tree:JIT/ --ci working-directory: ./src/tests - name: Run tests - run: /crossrootfs/riscv64/bin/qemu-riscv64-static /crossrootfs/riscv64/bin/bash -c ./run.sh Debug + run: qemu-riscv64-static /crossrootfs/riscv64/bin/bash -c ./run.sh Debug working-directory: ./src/tests - name: Upload Test error Log if: ${{ failure() }} From b054f820f08e993c1067ecc30c9737a95adce1fe Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 13:46:04 +0800 Subject: [PATCH 088/139] OP_LCONV_TO_OVF_I_UN --- src/mono/mono/mini/mini-riscv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 7d5e7c430eeaa..9712ceba6fad1 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1882,7 +1882,9 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LCONV_TO_U8: case OP_LCONV_TO_OVF_I: + case OP_LCONV_TO_OVF_I_UN: case OP_LCONV_TO_OVF_U: + case OP_LCONV_TO_OVF_U_UN: case OP_LCONV_TO_OVF_I1: case OP_LCONV_TO_OVF_I1_UN: case OP_LCONV_TO_OVF_U1: From a40363d99b259811d42dff49f228b8db412f2963 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 13:49:30 +0800 Subject: [PATCH 089/139] OP_COND_EXC_C --- src/mono/mono/mini/mini-riscv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 9712ceba6fad1..588dd9736c7c7 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3106,7 +3106,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) MonoInst *branch_ins = ins->next; if (branch_ins) { if (branch_ins->opcode == OP_COND_EXC_OV || ins->next->opcode == OP_COND_EXC_IOV || - branch_ins->opcode == OP_COND_EXC_NC) { + branch_ins->opcode == OP_COND_EXC_NC || branch_ins->opcode == OP_COND_EXC_C) { // bne t1, t2, overflow branch_ins->opcode = OP_RISCV_EXC_BNE; branch_ins->sreg1 = mono_alloc_ireg (cfg); From 76c4a7bf7c680d8e00129f628dd87db793d4e59c Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 13:50:25 +0800 Subject: [PATCH 090/139] loadr8_membase --- src/mono/mono/mini/cpu-riscv64.mdesc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 954fc5bf9fa16..a9c9498609de9 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -97,8 +97,8 @@ loadi2_membase: dest:i src1:b len:24 loadu4_membase: dest:i src1:b len:24 loadi4_membase: dest:i src1:b len:24 loadi8_membase: dest:i src1:b len:24 -loadr4_membase: dest:f src1:b len:16 -loadr8_membase: dest:f src1:b len:16 +loadr4_membase: dest:f src1:b len:24 +loadr8_membase: dest:f src1:b len:24 memory_barrier: len:4 atomic_add_i4: dest:i src1:i src2:i len:4 From 2e1824ba4c5ef6275040097ac9e2a3a0b2f00d14 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 13:54:34 +0800 Subject: [PATCH 091/139] OP_RCONV_TO_U2 --- src/mono/mono/mini/mini-riscv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 588dd9736c7c7..5523fdbde6614 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1846,6 +1846,10 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_U1: case OP_ICONV_TO_I2: case OP_ICONV_TO_U2: + case OP_RCONV_TO_I1: + case OP_RCONV_TO_U1: + case OP_RCONV_TO_I2: + case OP_RCONV_TO_U2: case OP_RCONV_TO_I4: case OP_RCONV_TO_U4: case OP_FCONV_TO_I1: From af4b542e6e1fc2fc4d1c23c7e64aae8416a44220 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 13:55:31 +0800 Subject: [PATCH 092/139] case OP_RCONV_TO_U4: --- src/mono/mono/mini/mini-riscv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 5523fdbde6614..9d31f40923989 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1852,6 +1852,8 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_RCONV_TO_U2: case OP_RCONV_TO_I4: case OP_RCONV_TO_U4: + case OP_RCONV_TO_I8: + case OP_RCONV_TO_U8: case OP_FCONV_TO_I1: case OP_FCONV_TO_U1: case OP_FCONV_TO_I2: From 503665651de175e335ada60c45213843deb5b05d Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 14:38:48 +0800 Subject: [PATCH 093/139] fix compile error --- src/mono/mono/mini/mini-riscv.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 9d31f40923989..95d7ddabccc02 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1852,8 +1852,6 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_RCONV_TO_U2: case OP_RCONV_TO_I4: case OP_RCONV_TO_U4: - case OP_RCONV_TO_I8: - case OP_RCONV_TO_U8: case OP_FCONV_TO_I1: case OP_FCONV_TO_U1: case OP_FCONV_TO_I2: @@ -1910,7 +1908,6 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_ICONV_TO_R8: case OP_LCONV_TO_R8: - case OP_RCONV_TO_I2: case OP_FCONV_TO_R4: case OP_FCONV_TO_R8: case OP_FCONV_TO_I8: @@ -1918,6 +1915,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_FCONV_TO_OVF_I8: case OP_FCONV_TO_OVF_U8: case OP_RCONV_TO_I8: + case OP_RCONV_TO_U8: case OP_RCONV_TO_OVF_I8: case OP_RCONV_TO_OVF_U8: #endif From 064c395d2453093d0397f2eeb7c41fdc6b8346e5 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 22:13:34 +0800 Subject: [PATCH 094/139] use next_inst instead of ins->next --- src/mono/mono/mini/mini-riscv.c | 405 ++++++++++++++++---------------- 1 file changed, 207 insertions(+), 198 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 95d7ddabccc02..3c60337ae82f3 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2243,11 +2243,12 @@ mono_arch_allocate_vars (MonoCompile *cfg) mono_bblock_insert_before_ins (bb, ins, (dest)); \ } while (0) -#define NEW_INS_AFTER(cfg, ins, dest, op) \ +#define NEW_INS_AFTER(cfg, ins, next_ins, dest, op) \ do { \ MONO_INST_NEW ((cfg), (dest), (op)); \ (dest)->cil_code = (ins)->cil_code; \ mono_bblock_insert_after_ins (bb, ins, (dest)); \ + next_ins = dest; \ } while (0) /* @@ -2259,7 +2260,7 @@ mono_arch_allocate_vars (MonoCompile *cfg) void mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) { - MonoInst *ins, *last_ins, *n, *temp; + MonoInst *ins, *last_ins, *next_ins, *temp; if (cfg->verbose_level > 2) { g_print ("BASIC BLOCK %d (before lowering)\n", bb->block_num); MONO_BB_FOR_EACH_INS (bb, ins) @@ -2268,7 +2269,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) } } - MONO_BB_FOR_EACH_INS_SAFE (bb, n, ins) + MONO_BB_FOR_EACH_INS_SAFE (bb, next_ins, ins) { loop_start: switch (ins->opcode) { @@ -2450,7 +2451,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->opcode = OP_FCEQ; else ins->opcode = OP_RCEQ; - NEW_INS_AFTER (cfg, ins, temp, OP_CEQ); + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_CEQ); temp->dreg = ins->dreg; temp->sreg1 = temp->dreg; temp->sreg2 = RISCV_ZERO; @@ -2470,13 +2471,13 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) // fconv_to_i1 rd, fs1 => fconv_to_i{4|8} rs1, fs1; {i|l}conv_to_i1 rd, rs1 int rd = ins->dreg; #ifdef TARGET_RISCV64 - NEW_INS_AFTER (cfg, ins, temp, OP_LCONV_TO_I1); + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_LCONV_TO_I1); if (ins->opcode == OP_FCONV_TO_I1) ins->opcode = OP_FCONV_TO_I8; else ins->opcode = OP_RCONV_TO_I8; #else - NEW_INS_AFTER (cfg, ins, temp, OP_ICONV_TO_I1); + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_ICONV_TO_I1); if (ins->opcode == OP_FCONV_TO_I1) ins->opcode = OP_FCONV_TO_I4; else @@ -2493,13 +2494,13 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) // fconv_to_u1 rd, fs1 => fconv_to_u{4|8} rs1, fs1; {i|l}conv_to_u1 rd, rs1 int rd = ins->dreg; #ifdef TARGET_RISCV64 - NEW_INS_AFTER (cfg, ins, temp, OP_LCONV_TO_U1); + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_LCONV_TO_U1); if (ins->opcode == OP_FCONV_TO_U1) ins->opcode = OP_FCONV_TO_U8; else ins->opcode = OP_RCONV_TO_U8; #else - NEW_INS_AFTER (cfg, ins, temp, OP_ICONV_TO_U1); + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_ICONV_TO_U1); if (ins->opcode == OP_FCONV_TO_U1) ins->opcode = OP_FCONV_TO_U4; else @@ -2516,13 +2517,13 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) // fconv_to_i2 rd, fs1 => fconv_to_i{4|8} rs1, fs1; {i|l}conv_to_i2 rd, rs1 int rd = ins->dreg; #ifdef TARGET_RISCV64 - NEW_INS_AFTER (cfg, ins, temp, OP_LCONV_TO_I2); + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_LCONV_TO_I2); if (ins->opcode == OP_FCONV_TO_I2) ins->opcode = OP_FCONV_TO_I8; else ins->opcode = OP_RCONV_TO_I8; #else - NEW_INS_AFTER (cfg, ins, temp, OP_ICONV_TO_I2); + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_ICONV_TO_I2); if (ins->opcode == OP_FCONV_TO_I2) ins->opcode = OP_FCONV_TO_I4; else @@ -2539,13 +2540,13 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) // fconv_to_u2 rd, fs1 => fconv_to_u{4|8} rs1, fs1; {i|l}conv_to_u2 rd, rs1 int rd = ins->dreg; #ifdef TARGET_RISCV64 - NEW_INS_AFTER (cfg, ins, temp, OP_LCONV_TO_U2); + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_LCONV_TO_U2); if (ins->opcode == OP_FCONV_TO_U2) ins->opcode = OP_FCONV_TO_U8; else ins->opcode = OP_RCONV_TO_U8; #else - NEW_INS_AFTER (cfg, ins, temp, OP_ICONV_TO_U2); + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_ICONV_TO_U2); if (ins->opcode == OP_FCONV_TO_U2) ins->opcode = OP_FCONV_TO_U4; else @@ -2565,15 +2566,15 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) break; } case OP_RCOMPARE: { - if (ins->next) { - if (ins->next->opcode == OP_FBLT || ins->next->opcode == OP_FBLT_UN) { + if (next_ins) { + if (next_ins->opcode == OP_FBLT || next_ins->opcode == OP_FBLT_UN) { ins->opcode = OP_RCLT; ins->dreg = mono_alloc_ireg (cfg); - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; - } else if (ins->next->opcode == OP_FBGT || ins->next->opcode == OP_FBGT_UN) { + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; + } else if (next_ins->opcode == OP_FBGT || next_ins->opcode == OP_FBGT_UN) { // rcmp rd, rs1, rs2; fbgt rd -> rcgt rd, rs1, rs2; bne rd, X0 // rcgt rd, rs1, rs2 -> flt.s rd, rs2, rs1 ins->opcode = OP_RCLT; @@ -2582,10 +2583,10 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->sreg1 = ins->sreg2; ins->sreg2 = tmp_reg; - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; - } else if (ins->next->opcode == OP_FBGE || ins->next->opcode == OP_FBGE_UN) { + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; + } else if (next_ins->opcode == OP_FBGE || next_ins->opcode == OP_FBGE_UN) { // rcmp rd, rs1, rs2; fbge rd -> rcle rd, rs2, rs1; bne rd, X0 ins->opcode = OP_RCLE; ins->dreg = mono_alloc_ireg (cfg); @@ -2593,35 +2594,35 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->sreg1 = ins->sreg2; ins->sreg2 = tmp_reg; - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; - } else if (ins->next->opcode == OP_FBLE || ins->next->opcode == OP_FBLE_UN) { + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; + } else if (next_ins->opcode == OP_FBLE || next_ins->opcode == OP_FBLE_UN) { ins->opcode = OP_RCLE; ins->dreg = mono_alloc_ireg (cfg); - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; - } else if (ins->next->opcode == OP_FBEQ) { + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; + } else if (next_ins->opcode == OP_FBEQ) { // rcmp rs1, rs2; fbeq rd -> rceq rd, rs1, rs2; bne rd, X0 ins->opcode = OP_RCEQ; ins->dreg = mono_alloc_ireg (cfg); - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; - } else if (ins->next->opcode == OP_FBNE_UN) { + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; + } else if (next_ins->opcode == OP_FBNE_UN) { // rcmp rs1, rs2; fbne rd -> rceq rd, rs1, rs2; beq rd, X0 ins->opcode = OP_RCEQ; ins->dreg = mono_alloc_ireg (cfg); - ins->next->opcode = OP_RISCV_BEQ; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; + next_ins->opcode = OP_RISCV_BEQ; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; } else { - g_print ("Unhandaled op %s following after OP_RCOMPARE\n", mono_inst_name (ins->next->opcode)); + g_print ("Unhandaled op %s following after OP_RCOMPARE\n", mono_inst_name (next_ins->opcode)); NOT_IMPLEMENTED; } } else { @@ -2630,15 +2631,15 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) break; } case OP_FCOMPARE: { - if (ins->next) { - if (ins->next->opcode == OP_FBLT || ins->next->opcode == OP_FBLT_UN) { + if (next_ins) { + if (next_ins->opcode == OP_FBLT || next_ins->opcode == OP_FBLT_UN) { ins->opcode = OP_FCLT; ins->dreg = mono_alloc_ireg (cfg); - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; - } else if (ins->next->opcode == OP_FBGT || ins->next->opcode == OP_FBGT_UN) { + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; + } else if (next_ins->opcode == OP_FBGT || next_ins->opcode == OP_FBGT_UN) { // fcmp rd, rs1, rs2; fbgt rd -> fclt rd, rs2, rs1; bne rd, X0 ins->opcode = OP_FCLT; ins->dreg = mono_alloc_ireg (cfg); @@ -2646,10 +2647,10 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->sreg1 = ins->sreg2; ins->sreg2 = tmp_reg; - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; - } else if (ins->next->opcode == OP_FBGE || ins->next->opcode == OP_FBGE_UN) { + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; + } else if (next_ins->opcode == OP_FBGE || next_ins->opcode == OP_FBGE_UN) { // fcmp rd, rs1, rs2; fbge rd -> fcle rd, rs2, rs1; bne rd, X0 ins->opcode = OP_FCLE; ins->dreg = mono_alloc_ireg (cfg); @@ -2657,38 +2658,38 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->sreg1 = ins->sreg2; ins->sreg2 = tmp_reg; - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; - } else if (ins->next->opcode == OP_FBLE || ins->next->opcode == OP_FBLE_UN){ + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; + } else if (next_ins->opcode == OP_FBLE || next_ins->opcode == OP_FBLE_UN){ ins->opcode = OP_FCLE; ins->dreg = mono_alloc_ireg (cfg); - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; - } else if (ins->next->opcode == OP_FBNE_UN) { + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; + } else if (next_ins->opcode == OP_FBNE_UN) { // fcmp rd, rs1, rs2; fbne rd -> fceq rd, rs1, rs2; beq rd, X0 ins->opcode = OP_FCEQ; ins->dreg = mono_alloc_ireg (cfg); ins->sreg1 = ins->sreg1; ins->sreg2 = ins->sreg2; - ins->next->opcode = OP_RISCV_BEQ; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; - } else if (ins->next->opcode == OP_FBEQ) { + next_ins->opcode = OP_RISCV_BEQ; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; + } else if (next_ins->opcode == OP_FBEQ) { // fcmp rd, rs1, rs2; fbeq rd -> fceq rd, rs1, rs2; bne rd, X0 ins->opcode = OP_FCEQ; ins->dreg = mono_alloc_ireg (cfg); ins->sreg1 = ins->sreg1; ins->sreg2 = ins->sreg2; - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->dreg; - ins->next->sreg2 = RISCV_ZERO; + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->dreg; + next_ins->sreg2 = RISCV_ZERO; } else { - g_print ("Unhandaled op %s following after OP_FCOMPARE\n", mono_inst_name (ins->next->opcode)); + g_print ("Unhandaled op %s following after OP_FCOMPARE\n", mono_inst_name (next_ins->opcode)); NOT_IMPLEMENTED; } } else { @@ -2856,57 +2857,57 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_COMPARE_IMM: case OP_ICOMPARE_IMM: case OP_LCOMPARE_IMM: { - if (ins->next) { - if (ins->next->opcode == OP_LCEQ || ins->next->opcode == OP_ICEQ) { + if (next_ins) { + if (next_ins->opcode == OP_LCEQ || next_ins->opcode == OP_ICEQ) { if (RISCV_VALID_I_IMM (ins->inst_imm)) { // compare rs1, imm; lceq rd => addi rs2, rs1, -imm; sltiu rd, rs2, 1 ins->opcode = OP_ADD_IMM; ins->dreg = mono_alloc_ireg (cfg); ins->inst_imm = -ins->inst_imm; - ins->next->opcode = OP_RISCV_SLTIU; - ins->next->sreg1 = ins->dreg; - ins->next->inst_imm = 1; + next_ins->opcode = OP_RISCV_SLTIU; + next_ins->sreg1 = ins->dreg; + next_ins->inst_imm = 1; break; } } - if (ins->next->opcode == OP_ICNEQ) { + if (next_ins->opcode == OP_ICNEQ) { if (RISCV_VALID_I_IMM (ins->inst_imm)) { // compare rs1, imm; lcneq rd => addi rs2, rs1, -imm; sltu rd, X0, rs2 ins->opcode = OP_ADD_IMM; ins->dreg = mono_alloc_ireg (cfg); ins->inst_imm = -ins->inst_imm; - ins->next->opcode = OP_RISCV_SLTU; - ins->next->sreg1 = RISCV_ZERO; - ins->next->sreg2 = ins->dreg; + next_ins->opcode = OP_RISCV_SLTU; + next_ins->sreg1 = RISCV_ZERO; + next_ins->sreg2 = ins->dreg; break; } - } else if (ins->next->opcode == OP_LCGT_UN || ins->next->opcode == OP_ICGT_UN) { + } else if (next_ins->opcode == OP_LCGT_UN || next_ins->opcode == OP_ICGT_UN) { if (RISCV_VALID_I_IMM (ins->inst_imm + 1)) { // compare rs1, imm; lcgt_un rd => sltiu rd, rs1, imm; xori rd, rd, 1 ins->opcode = OP_RISCV_SLTIU; - ins->dreg = ins->next->dreg; + ins->dreg = next_ins->dreg; ins->sreg1 = ins->sreg1; ins->inst_imm = ins->inst_imm + 1; - ins->next->opcode = OP_XOR_IMM; - ins->next->dreg = ins->dreg; - ins->next->sreg1 = ins->dreg; - ins->next->inst_imm = 1; + next_ins->opcode = OP_XOR_IMM; + next_ins->dreg = ins->dreg; + next_ins->sreg1 = ins->dreg; + next_ins->inst_imm = 1; break; } - } else if (ins->next->opcode == OP_LCGT || ins->next->opcode == OP_ICGT) { + } else if (next_ins->opcode == OP_LCGT || next_ins->opcode == OP_ICGT) { if (RISCV_VALID_I_IMM (ins->inst_imm + 1)) { ins->opcode = OP_RISCV_SLTI; - ins->dreg = ins->next->dreg; + ins->dreg = next_ins->dreg; ins->sreg1 = ins->sreg1; ins->inst_imm = ins->inst_imm + 1; - ins->next->opcode = OP_XOR_IMM; - ins->next->dreg = ins->dreg; - ins->next->sreg1 = ins->dreg; - ins->next->inst_imm = 1; + next_ins->opcode = OP_XOR_IMM; + next_ins->dreg = ins->dreg; + next_ins->sreg1 = ins->dreg; + next_ins->inst_imm = 1; break; } } @@ -2931,135 +2932,135 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_COMPARE: case OP_ICOMPARE: case OP_LCOMPARE: { - if (ins->next) { - if (ins->next->opcode == OP_COND_EXC_EQ || ins->next->opcode == OP_COND_EXC_IEQ) { - ins->next->opcode = OP_RISCV_EXC_BEQ; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + if (next_ins) { + if (next_ins->opcode == OP_COND_EXC_EQ || next_ins->opcode == OP_COND_EXC_IEQ) { + next_ins->opcode = OP_RISCV_EXC_BEQ; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_COND_EXC_NE_UN) { - ins->next->opcode = OP_RISCV_EXC_BNE; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_COND_EXC_NE_UN) { + next_ins->opcode = OP_RISCV_EXC_BNE; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_COND_EXC_LT || ins->next->opcode == OP_COND_EXC_ILT) { - ins->next->opcode = OP_RISCV_EXC_BLT; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_COND_EXC_LT || next_ins->opcode == OP_COND_EXC_ILT) { + next_ins->opcode = OP_RISCV_EXC_BLT; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_COND_EXC_LT_UN || ins->next->opcode == OP_COND_EXC_ILT_UN) { - ins->next->opcode = OP_RISCV_EXC_BLTU; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_COND_EXC_LT_UN || next_ins->opcode == OP_COND_EXC_ILT_UN) { + next_ins->opcode = OP_RISCV_EXC_BLTU; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_COND_EXC_LE_UN) { - ins->next->opcode = OP_RISCV_EXC_BGEU; - ins->next->sreg1 = ins->sreg2; - ins->next->sreg2 = ins->sreg1; + } else if (next_ins->opcode == OP_COND_EXC_LE_UN) { + next_ins->opcode = OP_RISCV_EXC_BGEU; + next_ins->sreg1 = ins->sreg2; + next_ins->sreg2 = ins->sreg1; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_COND_EXC_IGT || ins->next->opcode == OP_COND_EXC_GT) { - ins->next->opcode = OP_RISCV_EXC_BLT; - ins->next->sreg1 = ins->sreg2; - ins->next->sreg2 = ins->sreg1; + } else if (next_ins->opcode == OP_COND_EXC_IGT || next_ins->opcode == OP_COND_EXC_GT) { + next_ins->opcode = OP_RISCV_EXC_BLT; + next_ins->sreg1 = ins->sreg2; + next_ins->sreg2 = ins->sreg1; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_COND_EXC_IGT_UN || ins->next->opcode == OP_COND_EXC_GT_UN) { - ins->next->opcode = OP_RISCV_EXC_BLTU; - ins->next->sreg1 = ins->sreg2; - ins->next->sreg2 = ins->sreg1; + } else if (next_ins->opcode == OP_COND_EXC_IGT_UN || next_ins->opcode == OP_COND_EXC_GT_UN) { + next_ins->opcode = OP_RISCV_EXC_BLTU; + next_ins->sreg1 = ins->sreg2; + next_ins->sreg2 = ins->sreg1; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LBEQ || ins->next->opcode == OP_IBEQ) { - ins->next->opcode = OP_RISCV_BEQ; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_LBEQ || next_ins->opcode == OP_IBEQ) { + next_ins->opcode = OP_RISCV_BEQ; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LBNE_UN || ins->next->opcode == OP_IBNE_UN) { - ins->next->opcode = OP_RISCV_BNE; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_LBNE_UN || next_ins->opcode == OP_IBNE_UN) { + next_ins->opcode = OP_RISCV_BNE; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LBGE_UN || ins->next->opcode == OP_IBGE_UN) { - ins->next->opcode = OP_RISCV_BGEU; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_LBGE_UN || next_ins->opcode == OP_IBGE_UN) { + next_ins->opcode = OP_RISCV_BGEU; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LBGE || ins->next->opcode == OP_IBGE) { - ins->next->opcode = OP_RISCV_BGE; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_LBGE || next_ins->opcode == OP_IBGE) { + next_ins->opcode = OP_RISCV_BGE; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LBGT_UN || ins->next->opcode == OP_IBGT_UN) { - ins->next->opcode = OP_RISCV_BLTU; - ins->next->sreg1 = ins->sreg2; - ins->next->sreg2 = ins->sreg1; + } else if (next_ins->opcode == OP_LBGT_UN || next_ins->opcode == OP_IBGT_UN) { + next_ins->opcode = OP_RISCV_BLTU; + next_ins->sreg1 = ins->sreg2; + next_ins->sreg2 = ins->sreg1; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LBGT || ins->next->opcode == OP_IBGT) { - ins->next->opcode = OP_RISCV_BLT; - ins->next->sreg1 = ins->sreg2; - ins->next->sreg2 = ins->sreg1; + } else if (next_ins->opcode == OP_LBGT || next_ins->opcode == OP_IBGT) { + next_ins->opcode = OP_RISCV_BLT; + next_ins->sreg1 = ins->sreg2; + next_ins->sreg2 = ins->sreg1; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LBLE || ins->next->opcode == OP_IBLE) { + } else if (next_ins->opcode == OP_LBLE || next_ins->opcode == OP_IBLE) { // ble rs1, rs2 -> bge rs2, rs1 - ins->next->opcode = OP_RISCV_BGE; - ins->next->sreg1 = ins->sreg2; - ins->next->sreg2 = ins->sreg1; + next_ins->opcode = OP_RISCV_BGE; + next_ins->sreg1 = ins->sreg2; + next_ins->sreg2 = ins->sreg1; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LBLE_UN || ins->next->opcode == OP_IBLE_UN) { + } else if (next_ins->opcode == OP_LBLE_UN || next_ins->opcode == OP_IBLE_UN) { // ble rs1, rs2 -> bge rs2, rs1 - ins->next->opcode = OP_RISCV_BGEU; - ins->next->sreg1 = ins->sreg2; - ins->next->sreg2 = ins->sreg1; + next_ins->opcode = OP_RISCV_BGEU; + next_ins->sreg1 = ins->sreg2; + next_ins->sreg2 = ins->sreg1; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LBLT_UN || ins->next->opcode == OP_IBLT_UN) { - ins->next->opcode = OP_RISCV_BLTU; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_LBLT_UN || next_ins->opcode == OP_IBLT_UN) { + next_ins->opcode = OP_RISCV_BLTU; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LBLT || ins->next->opcode == OP_IBLT) { - ins->next->opcode = OP_RISCV_BLT; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_LBLT || next_ins->opcode == OP_IBLT) { + next_ins->opcode = OP_RISCV_BLT; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LCLT || ins->next->opcode == OP_ICLT) { - ins->next->opcode = OP_RISCV_SLT; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_LCLT || next_ins->opcode == OP_ICLT) { + next_ins->opcode = OP_RISCV_SLT; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LCLT_UN || ins->next->opcode == OP_ICLT_UN) { - ins->next->opcode = OP_RISCV_SLTU; - ins->next->sreg1 = ins->sreg1; - ins->next->sreg2 = ins->sreg2; + } else if (next_ins->opcode == OP_LCLT_UN || next_ins->opcode == OP_ICLT_UN) { + next_ins->opcode = OP_RISCV_SLTU; + next_ins->sreg1 = ins->sreg1; + next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LCEQ || ins->next->opcode == OP_ICEQ) { + } else if (next_ins->opcode == OP_LCEQ || next_ins->opcode == OP_ICEQ) { // compare rs1, rs2; lceq rd => xor rd, rs1, rs2; sltiu rd, rd, 1 ins->opcode = OP_IXOR; - ins->dreg = ins->next->dreg; + ins->dreg = next_ins->dreg; - ins->next->opcode = OP_RISCV_SLTIU; - ins->next->sreg1 = ins->dreg; - ins->next->inst_imm = 1; - } else if (ins->next->opcode == OP_ICNEQ) { + next_ins->opcode = OP_RISCV_SLTIU; + next_ins->sreg1 = ins->dreg; + next_ins->inst_imm = 1; + } else if (next_ins->opcode == OP_ICNEQ) { // compare rs1, rs2; lcneq rd => xor rd, rs1, rs2; sltu rd, X0, rd ins->opcode = OP_IXOR; - ins->dreg = ins->next->dreg; - - ins->next->opcode = OP_RISCV_SLTU; - ins->next->sreg1 = RISCV_ZERO; - ins->next->sreg2 = ins->dreg; - } else if (ins->next->opcode == OP_LCGT || ins->next->opcode == OP_ICGT) { - ins->next->opcode = OP_RISCV_SLT; - ins->next->sreg1 = ins->sreg2; - ins->next->sreg2 = ins->sreg1; + ins->dreg = next_ins->dreg; + + next_ins->opcode = OP_RISCV_SLTU; + next_ins->sreg1 = RISCV_ZERO; + next_ins->sreg2 = ins->dreg; + } else if (next_ins->opcode == OP_LCGT || next_ins->opcode == OP_ICGT) { + next_ins->opcode = OP_RISCV_SLT; + next_ins->sreg1 = ins->sreg2; + next_ins->sreg2 = ins->sreg1; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_LCGT_UN || ins->next->opcode == OP_ICGT_UN) { - ins->next->opcode = OP_RISCV_SLTU; - ins->next->sreg1 = ins->sreg2; - ins->next->sreg2 = ins->sreg1; + } else if (next_ins->opcode == OP_LCGT_UN || next_ins->opcode == OP_ICGT_UN) { + next_ins->opcode = OP_RISCV_SLTU; + next_ins->sreg1 = ins->sreg2; + next_ins->sreg2 = ins->sreg1; NULLIFY_INS (ins); - } else if (ins->next->opcode == OP_IL_SEQ_POINT || ins->next->opcode == OP_MOVE || - ins->next->opcode == OP_LOAD_MEMBASE || ins->next->opcode == OP_NOP || - ins->next->opcode == OP_LOADI4_MEMBASE || ins->next->opcode == OP_BR || - ins->next->opcode == OP_LOADI8_MEMBASE || ins->next->opcode == OP_ICONST || - ins->next->opcode == OP_I8CONST || ins->next->opcode == OP_ADD_IMM) { + } else if (next_ins->opcode == OP_IL_SEQ_POINT || next_ins->opcode == OP_MOVE || + next_ins->opcode == OP_LOAD_MEMBASE || next_ins->opcode == OP_NOP || + next_ins->opcode == OP_LOADI4_MEMBASE || next_ins->opcode == OP_BR || + next_ins->opcode == OP_LOADI8_MEMBASE || next_ins->opcode == OP_ICONST || + next_ins->opcode == OP_I8CONST || next_ins->opcode == OP_ADD_IMM) { /** * there is compare without branch OP followed * @@ -3072,7 +3073,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) break; } else { g_print ("Unhandaled op %s following after OP_{I|L}COMPARE{|_IMM}\n", - mono_inst_name (ins->next->opcode)); + mono_inst_name (next_ins->opcode)); NOT_IMPLEMENTED; } } else @@ -3107,9 +3108,9 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->opcode = OP_LSUB; else ins->opcode = OP_ISUB; - MonoInst *branch_ins = ins->next; + MonoInst *branch_ins = next_ins; if (branch_ins) { - if (branch_ins->opcode == OP_COND_EXC_OV || ins->next->opcode == OP_COND_EXC_IOV || + if (branch_ins->opcode == OP_COND_EXC_OV || next_ins->opcode == OP_COND_EXC_IOV || branch_ins->opcode == OP_COND_EXC_NC || branch_ins->opcode == OP_COND_EXC_C) { // bne t1, t2, overflow branch_ins->opcode = OP_RISCV_EXC_BNE; @@ -3157,7 +3158,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) #endif ins->opcode = OP_IADD; - MonoInst *branch_ins = ins->next; + MonoInst *branch_ins = next_ins; if (branch_ins) { if (branch_ins->opcode == OP_COND_EXC_C || branch_ins->opcode == OP_COND_EXC_IC || branch_ins->opcode == OP_COND_EXC_OV || branch_ins->opcode == OP_COND_EXC_IOV) { @@ -4810,6 +4811,22 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fcvt_l_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); break; } + case OP_FCONV_TO_I8: { + g_assert (riscv_stdext_f || riscv_stdext_d); + if (riscv_stdext_d) + riscv_fcvt_l_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + else + riscv_fcvt_l_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + break; + } + case OP_FCONV_TO_U8: { + g_assert (riscv_stdext_f || riscv_stdext_d); + if (riscv_stdext_d) + riscv_fcvt_lu_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + else + riscv_fcvt_lu_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + break; + } case OP_RCONV_TO_I4: { g_assert (riscv_stdext_f); riscv_fcvt_w_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); @@ -4828,14 +4845,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fcvt_w_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); break; } - case OP_FCONV_TO_I8: { - g_assert (riscv_stdext_f || riscv_stdext_d); - if (riscv_stdext_d) - riscv_fcvt_l_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); - else - riscv_fcvt_l_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); - break; - } case OP_FCONV_TO_U4:{ g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) From 9e22f005bdccc79d260a652c9f3c94127d01c073 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 22:13:49 +0800 Subject: [PATCH 095/139] update --- src/mono/sample/TestRun/Makefile | 368 +----------------- .../sample/TestRun/TestRun.runtimeconfig.json | 9 + 2 files changed, 25 insertions(+), 352 deletions(-) create mode 100644 src/mono/sample/TestRun/TestRun.runtimeconfig.json diff --git a/src/mono/sample/TestRun/Makefile b/src/mono/sample/TestRun/Makefile index 00ce02d47c40a..67d5cae79125e 100644 --- a/src/mono/sample/TestRun/Makefile +++ b/src/mono/sample/TestRun/Makefile @@ -8,7 +8,7 @@ TARGET_OS=linux AOT?=false QEMU=qemu-riscv64-static SAMPLE_PATH=/home/wuxinlong/workspace/samples/csharp/getting-started/console-webapiclient -ANY_PATH= /home/wuxinlong/workspace/samples/orleans/HelloWorld/bin/Debug/net8.0/HelloWorld.dll +ANY_PATH= /home/wuxinlong/workspace/runtime/artifacts/tests/coreclr/linux.riscv64.Debug/JIT/jit64/regress/ddb/127931/127931/127931.dll GitHubKey=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 @@ -17,7 +17,7 @@ GitHubKey=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 #MIBC_PROFILE_PATH= MONO_ENV_DEBUG_OPTIONS = "-v" -MONO_ENV_RUN_OPTIONS = "--trace=all" +MONO_ENV_RUN_OPTIONS="" build: TestRun.cs @mcs TestRun.cs @@ -41,8 +41,7 @@ run: build run-any: COMPlus_DebugWriteToStdErr=1 \ MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(ANY_PATH) + ${CORE_ROOT}/corerun -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true $(ANY_PATH) run-webapiclient-baseline: COMPlus_DebugWriteToStdErr=1 \ @@ -85,26 +84,25 @@ debug-webapiclient: debug-any: COMPlus_DebugWriteToStdErr=1 \ MONO_ENV_OPTIONS=$(MONO_ENV_DEBUG_OPTIONS) \ - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ \ - -g 12345 \ - $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(ANY_PATH) &\ + $(QEMU) -g 12345 \ + ${CORE_ROOT}/corerun -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true $(ANY_PATH) &\ gdb-multiarch -ex 'target remote localhost:12345' \ -iex "add-auto-load-safe-path /home/wuxinlong/workspace/runtime/src/mono/sample/TestRun/" \ -ex "set sysroot $(TOP).tools/rootfs/riscv64" \ - -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/shared/Microsoft.NETCore.App/8.0.0" \ - -ex "b mini.c:2156" \ + -ex "set solib-search-path ${CORE_ROOT}" \ + -ex "b mini.c:2161" \ -ex "handle SIG35 print nostop ignore" \ - $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet + ${CORE_ROOT}/corerun remote_gdb: - gdb-multiarch -ex 'target remote localhost:12345' \ + gdb-multiarch -ex 'target remote localhost:32427' \ -iex "add-auto-load-safe-path /home/wuxinlong/workspace/runtime/src/mono/sample/TestRun/" \ -ex "set sysroot $(TOP).tools/rootfs/riscv64" \ -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/shared/Microsoft.NETCore.App/8.0.0" \ - -ex "b mono_break" \ + -ex "b mini.c:2156" \ -ex "handle SIG35 print nostop ignore" \ - $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet + ${CORE_ROOT}/corerun + debug-any-baseline: COMPlus_DebugWriteToStdErr=1 \ @@ -117,37 +115,11 @@ debug-any-baseline: clean: rm -f *.exe *.exe.mdb -# 0x4015437b1a - -# System.Runtime.CompilerServices.AsyncTaskMethodBuilder:SetException -# 1248 +0xd4 -# System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException -# +0x118 -# System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Create -# 311 +# ILGEN_0xf64b7da3:Method_0xcb0b0b48 +# 306 -# TeleprompterConsole.Program/d__2:MoveNext () -# 322 +0xec - -# TeleprompterConsole.Program:ShowTeleprompter -# 319 +0xcc - - -# Microsoft.CodeAnalysis.Syntax.InternalSyntax.SyntaxListBuilder:ToListNode -# 829 -# c 87 -# 0x4002c1abf8 - -# Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken:Create -# 831 -# +0x848 -# c 5 - -# Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax.SyntaxToken/SyntaxTokenWithTrivia:.ctor -# 0xe8 -# Microsoft.CodeAnalysis.GreenNode:AdjustFlagsAndWidth -# 0xd4 +# converting method PrimitiveVT.VT1B PrimitiveVT.CallConv3:f2 (PrimitiveVT.VT1A,PrimitiveVT.VT1B) # COMPlus_DebugWriteToStdErr="1" MONO_LOG_LEVEL="debug" MONO_LOG_MASK="all" COREHOST_TRACE="1" COREHOST_TRACE_VERBOSITY="4" MONO_ENV_OPTIONS="--compile-all --trace=all" qemu-riscv64 -L ../../../..//.tools/rootfs/riscv64/ -g 12345 ../../../../artifacts/bin/testhost/net8.0-Linux-Debug-riscv64/dotnet TestRun.exe @@ -157,315 +129,7 @@ clean: # ROOTFS_DIR="" ./build.sh clr.hosts -c Debug # ROOTFS_DIR="" ./build.sh mono+libs+host -c Debug --ninja /p:KeepNativeSymbols=true -# ./build.sh mono+libs+host -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build +# ./build.sh mono+libs+host+clr.host -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build # ./build.sh -mono -debug riscv64 -ninja /p:KeepNativeSymbols=true # ./build.sh clr.hosts --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true - -TEST_PATH=/home/wuxinlong/workspace/samples/ - -customer-relationship: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/tutorials/default-interface-members-versions/finished/customer-relationship/bin/Debug/net8.0/customer-relationship.dll - -exploration: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/tutorials/exploration/csharp6-finished/bin/Debug/net8.0/csharp6-finished.dll - -toll-calculator: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/tutorials/patterns/finished/toll-calculator/bin/Debug/net8.0/toll-calculator.dll - -mixins-with-interfaces: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/tutorials/mixins-with-interfaces/bin/Debug/net8.0/mixins-with-interfaces.dll - -datetime-parse: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/api/datetime.parse/bin/Debug/net8.0/datetime.parse.dll - -delegates-and-events: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/delegates-and-events/bin/Debug/net8.0/delegates-and-events.dll - -branches-quickstart: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/branches-quickstart/bin/Debug/net8.0/BranchesAndLoops.dll - -events: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/events/bin/Debug/net8.0/events.dll - -expression-trees: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/expression-trees/bin/Debug/net8.0/expression-trees.dll - -indexers: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/indexers/bin/Debug/net8.0/indexers.dll - -iterators: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/iterators/bin/Debug/net8.0/iterators.dll - -list-quickstart: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/list-quickstart/bin/Debug/net8.0/list-quickstart.dll - -NullableIntroduction: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/NullableIntroduction/NullableIntroduction/bin/Debug/net8.0/NullableIntroduction.dll - -numbers-quickstart: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/numbers-quickstart/bin/Debug/net8.0/NumbersInCSharp.dll - -PatternMatching: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/PatternMatching/bin/Debug/net8.0/PatternMatching.dll - -ref-tutorial: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/ref-tutorial/IntruderAlert-finished/bin/Debug/net8.0/IntruderAlert.dll - -versioning-new: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/versioning/new/bin/Debug/net8.0/new.dll - -versioning-override: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/versioning/override/bin/Debug/net8.0/override.dll - -fibonacci-msbuild: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/console-apps/fibonacci-msbuild/bin/Debug/net8.0/Hello.dll - -FibonacciBetterMsBuild: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/console-apps/FibonacciBetterMsBuild/bin/Debug/net8.0/Fibonacci.dll - -serialization: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/serialization/bin/Debug/net8.0/serialization.dll - -string_format: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/api/string.format/bin/Debug/net8.0/string.format.examples.dll - -classes-quickstart: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/classes-quickstart/bin/Debug/net8.0/classes.dll - -console-linq: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/getting-started/console-linq/bin/Debug/net8.0/console-linq.dll - -console-teleprompter: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/getting-started/console-teleprompter/bin/Debug/net8.0/console-teleprompter.dll - -console-webapiclient: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)csharp/getting-started/console-webapiclient/bin/Debug/net8.0/webapiclient.dll - -MetadataLoadContext: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/assembly/MetadataLoadContext/bin/Debug/net8.0/MetadataLoadContextSample.dll - -HelloMsBuild: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/console-apps/HelloMsBuild/bin/Debug/net8.0/Hello.dll - -DllMapDemo: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/extensions/DllMapDemo/bin/Debug/net8.0/Demo.dll - -AppWithPlugin: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/extensions/AppWithPlugin/AppWithPlugin/bin/Debug/net8.0/AppWithPlugin.dll - -AssemblyLoading: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/extensions/AssemblyLoading/AssemblyLoading/bin/Debug/net8.0/AssemblyLoading.dll - -cyrillic-to-latin: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/encoding/cyrillic-to-latin/cs/bin/Debug/net8.0/CyrillicToLatin.dll - -linker: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linker/TrimmedWithAdditionalRoots/bin/Debug/net8.0/TrimmedWithAdditionalRoots.dll - -linq/aggregate: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/aggregate/bin/Debug/net8.0/aggregate.dll - -linq/concatenation: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/concatenation/bin/Debug/net8.0/concatenation.dll - -linq/conversion: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/conversion/bin/Debug/net8.0/conversion.dll - -linq/customsequence: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/customsequence/bin/Debug/net8.0/customsequence.dll - -linq/element: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/element/bin/Debug/net8.0/element.dll - -linq/equality: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/equality/bin/Debug/net8.0/equality.dll - -linq/generation: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/generation/bin/Debug/net8.0/generation.dll - -linq/grouping: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/grouping/bin/Debug/net8.0/grouping.dll - -linq/join: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/join/bin/Debug/net8.0/join.dll - -linq/ordering: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/ordering/bin/Debug/net8.0/ordering.dll - -linq/partitioning: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/partitioning/bin/Debug/net8.0/partitioning.dll - -linq/quantifier: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/quantifier/bin/Debug/net8.0/quantifier.dll - -linq/queryexecution: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/queryexecution/bin/Debug/net8.0/queryexecution.dll - -linq/restriction: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/restriction/bin/Debug/net8.0/restriction.dll - -linq/setoperators: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/linq/csharp/setoperators/bin/Debug/net8.0/setoperators.dll - -logging/console-formatter-custom: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/logging/console-formatter-custom/bin/Debug/net8.0/console-formatter-custom.dll - -logging/console-formatter-custom-with-config: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/logging/console-formatter-custom-with-config/bin/Debug/net8.0/console-formatter-custom-with-config.dll - -logging/console-formatter-simple: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/logging/console-formatter-simple/bin/Debug/net8.0/console-formatter-simple.dll - -logging/console-formatter-systemd: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/logging/console-formatter-systemd/bin/Debug/net8.0/console-formatter-systemd.dll - -logging/logger-message-generator: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/logging/logger-message-generator/bin/Debug/net8.0/logger-message-generator.dll - -logging/worker-service-options: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/logging/worker-service-options/bin/Debug/net8.0/worker-service-options.dll - -whats-new: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/whats-new/whats-new-in-21/cs/bin/Debug/net8.0/whats-new.dll - -workers/background-service: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/workers/background-service/bin/Debug/net8.0/App.WorkerService.dll - -workers/cloud-service: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/workers/cloud-service/bin/Debug/net8.0/App.CloudService.dll - -workers/queue-service: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/workers/queue-service/bin/Debug/net8.0/App.QueueService.dll - -workers/scoped-service: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)core/workers/scoped-service/bin/Debug/net8.0/App.ScopedService.dll - -workers/timer-service: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/core/workers/timer-service/bin/Debug/net8.0/App.TimerHostedService.dll - -parallel/ComputePi: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/parallel/ComputePi/bin/Debug/net8.0/ComputePi.dll - -parallel/EditDistance: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/parallel/EditDistance/bin/Debug/net8.0/EditDistance.dll - -parallel/PLINQ: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/parallel/PLINQ/bin/Debug/net8.0/PLINQ.dll - -safe-efficient-code/ref-readonly-struct: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/safe-efficient-code/ref-readonly-struct/bin/Debug/net8.0/ref-readonly-struct.dll - -unit-testing/XUnit.TestProject: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/unit-testing/XUnit.TestProject/bin/Debug/net8.0/XUnit.Project.dll - -unit-testing/NUnit.TestProject: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/unit-testing/NUnit.TestProject/bin/Debug/net8.0/NUnit.Project.dll - -unit-testing/MSTest.Project: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/unit-testing/MSTest.Project/bin/Debug/net8.0/MSTest.Project.dll - -unit-testing-code-coverage: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/unit-testing-code-coverage/XUnit.Coverlet.Collector/bin/Debug/net8.0/XUnit.Coverlet.Collector.dll - -roslyn-sdk/Tutorials: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/roslyn-sdk/Tutorials/MakeConstTestProject/MakeConstTestProject/bin/Debug/net8.0/MakeConstTestProject.dll - -roslyn-sdk/HelloSyntaxTree: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/roslyn-sdk/SyntaxQuickStart/HelloSyntaxTree/bin/Debug/net8.0/HelloSyntaxTree.dll - -roslyn-sdk/SyntaxWalker: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/roslyn-sdk/SyntaxQuickStart/SyntaxWalker/bin/Debug/net8.0/SyntaxWalker.dll - -roslyn-sdk/SemanticQuickStart: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/roslyn-sdk/SemanticQuickStart/bin/Debug/net8.0/SemanticQuickStart.dll - -roslyn-sdk/ConstructionCS: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/roslyn-sdk/SyntaxTransformationQuickStart/ConstructionCS/bin/Debug/net8.0/ConstructionCS.dll - -roslyn-sdk/TransformationCS: - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(TEST_PATH)/csharp/roslyn-sdk/SyntaxTransformationQuickStart/TransformationCS/bin/Debug/net8.0/TransformationCS.dll - - -test: customer-relationship exploration toll-calculator mixins-with-interfaces delegates-and-events branches-quickstart \ -events expression-trees indexers list-quickstart NullableIntroduction numbers-quickstart PatternMatching versioning-new \ -versioning-override fibonacci-msbuild classes-quickstart console-linq console-webapiclient MetadataLoadContext HelloMsBuild \ -DllMapDemo AppWithPlugin AssemblyLoading cyrillic-to-latin linker linq/aggregate linq/concatenation linq/conversion linq/customsequence \ -linq/element linq/equality linq/generation linq/grouping linq/join linq/ordering linq/partitioning linq/quantifier linq/queryexecution \ -linq/restriction linq/setoperators logging/console-formatter-custom logging/console-formatter-simple logging/console-formatter-systemd \ -logging/logger-message-generator whats-new safe-efficient-code/ref-readonly-struct unit-testing/XUnit.TestProject unit-testing/NUnit.TestProject \ -unit-testing/MSTest.Project unit-testing-code-coverage roslyn-sdk/Tutorials roslyn-sdk/HelloSyntaxTree roslyn-sdk/SyntaxWalker \ No newline at end of file diff --git a/src/mono/sample/TestRun/TestRun.runtimeconfig.json b/src/mono/sample/TestRun/TestRun.runtimeconfig.json new file mode 100644 index 0000000000000..ef8c92c382190 --- /dev/null +++ b/src/mono/sample/TestRun/TestRun.runtimeconfig.json @@ -0,0 +1,9 @@ +{ + "runtimeOptions": { + "tfm": "net9.0", + "framework": { + "name": "Microsoft.NETCore.App", + "version": "9.0.0" + } + } + } \ No newline at end of file From d4fcc74e437683078df841aaf4282ca91bc6f660 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 22:15:47 +0800 Subject: [PATCH 096/139] OP_COND_EXC_IC --- src/mono/mono/mini/mini-riscv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 3c60337ae82f3..b3205ee57e662 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3111,7 +3111,8 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) MonoInst *branch_ins = next_ins; if (branch_ins) { if (branch_ins->opcode == OP_COND_EXC_OV || next_ins->opcode == OP_COND_EXC_IOV || - branch_ins->opcode == OP_COND_EXC_NC || branch_ins->opcode == OP_COND_EXC_C) { + branch_ins->opcode == OP_COND_EXC_NC || branch_ins->opcode == OP_COND_EXC_C || + branch_ins->opcode == OP_COND_EXC_IC) { // bne t1, t2, overflow branch_ins->opcode = OP_RISCV_EXC_BNE; branch_ins->sreg1 = mono_alloc_ireg (cfg); From a5be33120281a858aaabe423122ae3a0e0f95da4 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 22:15:53 +0800 Subject: [PATCH 097/139] int_xor_imm --- src/mono/mono/mini/cpu-riscv64.mdesc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index a9c9498609de9..2b31cbab38b10 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -206,6 +206,7 @@ long_and: dest:i src1:i src2:i len:4 long_and_imm: dest:i src1:i len:4 long_or: dest:i src1:i src2:i len:4 long_xor: dest:i src1:i src2:i len:4 +int_xor_imm: dest:i src1:i len:4 long_or_imm: dest:i src1:i len:4 long_shl: dest:i src1:i src2:i len:4 long_shl_imm: dest:i src1:i len:4 From 1aed6db50ff0d9e0837792f0bd437bff937a28ca Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 20 Dec 2023 22:17:39 +0800 Subject: [PATCH 098/139] r4_conv_to_u8 --- src/mono/mono/mini/cpu-riscv64.mdesc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 2b31cbab38b10..b00d242572a2e 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -164,6 +164,7 @@ r4_conv_to_i8: dest:i src1:f len:4 r4_conv_to_r8: dest:f src1:f len:4 r4_conv_to_i4: dest:i src1:f len:4 r4_conv_to_u4: dest:i src1:f len:4 +r4_conv_to_u8: dest:i src1:f len:4 float_conv_to_i4: dest:i src1:f len:4 float_conv_to_u4: dest:i src1:f len:4 float_conv_to_r4: dest:f src1:f len:4 From 70dc7963c730c4ee87acee40b4bc8595ebe2132b Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 10:15:37 +0800 Subject: [PATCH 099/139] trace_diff.py --- src/mono/sample/TestRun/trace_diff.py | 71 +++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/mono/sample/TestRun/trace_diff.py diff --git a/src/mono/sample/TestRun/trace_diff.py b/src/mono/sample/TestRun/trace_diff.py new file mode 100644 index 0000000000000..c237455e6bccb --- /dev/null +++ b/src/mono/sample/TestRun/trace_diff.py @@ -0,0 +1,71 @@ +import sys +import re + +def compare_stacks(file1_path, file2_path): + try: + with open(file1_path, "r") as file1, open(file2_path, "r") as file2: + baseline_lines = file1.readlines() + comparison_lines = file2.readlines() + + index1, index2 = 0, 0 + last_command = None + + while index1 < len(baseline_lines) and index2 < len(comparison_lines): + stack1 = baseline_lines[index1].strip() + stack2 = comparison_lines[index2].strip() + + # 使用正则表达式匹配重要信息 + pattern = re.compile(r'(\[([^:]+): ([\d.]+) (\d+)\]) (ENTER|LEAVE):c (.+?) (\(.*?\)|\()(\(.+?\)|\()') + match1 = pattern.match(stack1) + match2 = pattern.match(stack2) + + if match1 and match2: + sameStackDeeps = match1.group(4) == match2.group(4) + sameFuncAction = match1.group(5) == match2.group(5) + sameFuncSig = match1.group(6) == match2.group(6) and match1.group(7) == match2.group(7) + file1Param = match1.group(8) + file2Param = match1.group(8) + if sameStackDeeps and sameFuncAction and sameFuncSig: + # print(f"Stacks are identical at line {index1 + 1}") + index1 += 1 + index2 += 1 + else: + print(f"Difference found at") + print(f"File 1, Line {index1 + 1}: {stack1}") + print(f"File 2, Line {index2 + 1}: {stack2}") + command = input("Enter '1' to move File 1 to the next line, '2' to move File 2 to the next line, 'q' to quit: ") + + if command == '': + command = last_command + + if command == '1': + index1 += 1 + elif command == '2': + index2 += 1 + elif command == 'q': + break + else: + print("Invalid command. Please enter '1', '2', or 'q'.") + + last_command = command + else: + # 如果无法匹配到重要信息,直接跳到下一行 + print(stack1) + print(stack2) + index1 += 1 + index2 += 1 + + print("Comparison complete.") + + except FileNotFoundError as e: + print(f"Error: {e.filename} not found.") + except Exception as e: + print(f"An error occurred: {e}") + +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: python trace_diff.py ") + else: + baseline_file_path = sys.argv[1] + comparison_file_path = sys.argv[2] + compare_stacks(baseline_file_path, comparison_file_path) From d19ee8cff6aef34bb5569ac870bc8a69514b48f3 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 12:34:43 +0800 Subject: [PATCH 100/139] set RISCV_ROUND_TZ for OP_{R|F}CONV_TO_ --- src/mono/mono/mini/mini-riscv.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index b3205ee57e662..9fee0152d9e12 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -4809,55 +4809,55 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) } case OP_RCONV_TO_I8: { g_assert (riscv_stdext_f); - riscv_fcvt_l_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_l_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } case OP_FCONV_TO_I8: { g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) - riscv_fcvt_l_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_l_d (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); else - riscv_fcvt_l_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_l_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } case OP_FCONV_TO_U8: { g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) - riscv_fcvt_lu_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_lu_d (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); else - riscv_fcvt_lu_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_lu_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } case OP_RCONV_TO_I4: { g_assert (riscv_stdext_f); - riscv_fcvt_w_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_w_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } case OP_RCONV_TO_U4: { g_assert (riscv_stdext_f); - riscv_fcvt_wu_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_wu_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } case OP_FCONV_TO_I4: { g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) - riscv_fcvt_w_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_w_d (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); else - riscv_fcvt_w_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_w_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } case OP_FCONV_TO_U4:{ g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) - riscv_fcvt_wu_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_wu_d (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); else - riscv_fcvt_wu_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_wu_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } case OP_FCONV_TO_R4: case OP_RISCV_SETFREG_R4: { g_assert (riscv_stdext_d); - riscv_fcvt_s_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1); + riscv_fcvt_s_d (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } case OP_RDIV: { From 0d44b0fdd815a99401661e2b8047acb4c825cdaf Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 12:46:53 +0800 Subject: [PATCH 101/139] update --- riscv64_build_test.sh | 4 ++++ src/mono/sample/TestRun/.gdbinit | 29 +++++++++++++++++++++++++++++ src/mono/sample/TestRun/Makefile | 17 +++++++++-------- src/mono/sample/TestRun/TestRun.cs | 23 +++++++++++++++++++++++ src/tests/run.py | 2 +- 5 files changed, 66 insertions(+), 9 deletions(-) create mode 100755 riscv64_build_test.sh create mode 100644 src/mono/sample/TestRun/.gdbinit create mode 100644 src/mono/sample/TestRun/TestRun.cs diff --git a/riscv64_build_test.sh b/riscv64_build_test.sh new file mode 100755 index 0000000000000..2c39779391727 --- /dev/null +++ b/riscv64_build_test.sh @@ -0,0 +1,4 @@ +cd src/tests +./build.sh -mono -debug riscv64 -ninja /p:KeepNativeSymbols=true -tree:JIT/ + +cd ../.. \ No newline at end of file diff --git a/src/mono/sample/TestRun/.gdbinit b/src/mono/sample/TestRun/.gdbinit new file mode 100644 index 0000000000000..ae092457a95f4 --- /dev/null +++ b/src/mono/sample/TestRun/.gdbinit @@ -0,0 +1,29 @@ +handle SIGXCPU SIG33 SIG35 SIG36 SIG37 SIG38 SIGPWR nostop print + +define mono_backtrace + select-frame 0 + set $i = 0 + while ($i < $arg0) + set $foo = (char*) mono_pmip ($pc) + if ($foo) + printf "#%d %p in %s\n", $i, $pc, $foo + else + frame + end + up-silently + set $i = $i + 1 + end +end + +define mono_stack + set $mono_thread = mono_thread_current () + if ($mono_thread == 0x00) + printf "No mono thread associated with this thread\n" + else + set $ucp = malloc (sizeof (ucontext_t)) + call (void) getcontext ($ucp) + call (void) mono_print_thread_dump ($ucp) + call (void) free ($ucp) + end +end + diff --git a/src/mono/sample/TestRun/Makefile b/src/mono/sample/TestRun/Makefile index 67d5cae79125e..99055040cd625 100644 --- a/src/mono/sample/TestRun/Makefile +++ b/src/mono/sample/TestRun/Makefile @@ -8,7 +8,8 @@ TARGET_OS=linux AOT?=false QEMU=qemu-riscv64-static SAMPLE_PATH=/home/wuxinlong/workspace/samples/csharp/getting-started/console-webapiclient -ANY_PATH= /home/wuxinlong/workspace/runtime/artifacts/tests/coreclr/linux.riscv64.Debug/JIT/jit64/regress/ddb/127931/127931/127931.dll +CORE_BASELINE_ROOT=/home/wuxinlong/workspace/runtime/artifacts/tests/coreclr/linux.x64.Debug/Tests/Core_Root +ANY_PATH= /home/wuxinlong/workspace/runtime/artifacts/tests/coreclr/linux.x64.Debug/JIT/Directed/Directed_3/Directed_3.dll GitHubKey=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 @@ -16,7 +17,7 @@ GitHubKey=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 #PGO_BINARY_PATH= #MIBC_PROFILE_PATH= -MONO_ENV_DEBUG_OPTIONS = "-v" +MONO_ENV_DEBUG_OPTIONS = "-v --trace=all --break StrAccess1:Run" MONO_ENV_RUN_OPTIONS="" build: TestRun.cs @@ -30,13 +31,13 @@ run-baseline: build run-any-baseline: COMPlus_DebugWriteToStdErr=1 \ MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ - $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-x64/dotnet \ - $(ANY_PATH) + CORE_ROOT=${CORE_BASELINE_ROOT} \ + ${CORE_BASELINE_ROOT}/corerun -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true $(ANY_PATH) run: build @COMPlus_DebugWriteToStdErr=1 \ MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet TestRun.exe + $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net9.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet TestRun.exe run-any: COMPlus_DebugWriteToStdErr=1 \ @@ -90,8 +91,8 @@ debug-any: -iex "add-auto-load-safe-path /home/wuxinlong/workspace/runtime/src/mono/sample/TestRun/" \ -ex "set sysroot $(TOP).tools/rootfs/riscv64" \ -ex "set solib-search-path ${CORE_ROOT}" \ - -ex "b mini.c:2161" \ - -ex "handle SIG35 print nostop ignore" \ + -ex "b mono_break" \ + -ex "handle SIGXCPU SIG33 SIG35 SIG36 SIG37 SIG38 SIGPWR print nostop ignore" \ ${CORE_ROOT}/corerun remote_gdb: @@ -130,6 +131,6 @@ clean: # ROOTFS_DIR="" ./build.sh mono+libs+host -c Debug --ninja /p:KeepNativeSymbols=true # ./build.sh mono+libs+host+clr.host -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build - +# CORT_ROOT=/home/wuxinlong/workspace/runtime/artifacts/tests/coreclr/linux.x64.Debug # ./build.sh -mono -debug riscv64 -ninja /p:KeepNativeSymbols=true # ./build.sh clr.hosts --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true diff --git a/src/mono/sample/TestRun/TestRun.cs b/src/mono/sample/TestRun/TestRun.cs new file mode 100644 index 0000000000000..6f963afbf91d5 --- /dev/null +++ b/src/mono/sample/TestRun/TestRun.cs @@ -0,0 +1,23 @@ +// C# Hello World + +using System; + +public class Test +{ + public static void TestRun() + { + int i; + int len = 50; + var rand = new Random(); + while (len != 0) + { + i = rand.Next(0, 1); + len /= 2; + } + } + + public static void Main() + { + TestRun(); + } +} \ No newline at end of file diff --git a/src/tests/run.py b/src/tests/run.py index 9c30ded6a1678..a2d62d532b947 100755 --- a/src/tests/run.py +++ b/src/tests/run.py @@ -806,7 +806,7 @@ def run_tests(args, """ # Set default per-test timeout to 2 minutes (in milliseconds). - per_test_timeout = 2*60*1000 + per_test_timeout = 4*60*1000 # Setup the environment if args.long_gc: From bc3f062c73453511a9e2cff19ee222e0f190b5ad Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 15:56:39 +0800 Subject: [PATCH 102/139] emit OP_LSUB when OP_SUBCC --- src/mono/mono/mini/mini-riscv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 9fee0152d9e12..93fc27f10915f 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3104,7 +3104,14 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) * slt t2, rd, rs1 * bne t1, t2, overflow */ - if (ins->opcode == OP_LSUBCC) + if (ins->opcode == OP_SUBCC){ +#ifdef TARGET_RISCV64 + ins->opcode = OP_LSUB; +#else + ins->opcode = OP_ISUB; +#endif + } + else if (ins->opcode == OP_LSUBCC) ins->opcode = OP_LSUB; else ins->opcode = OP_ISUB; @@ -3151,7 +3158,6 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) * slt t4,t0,t1 * bne t3, t4, overflow */ - #ifdef TARGET_RISCV64 if (ins->opcode == OP_ADDCC) ins->opcode = OP_LADD; From 729da3039393ceb3672e6795a500eb3eaa3ac9fe Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 15:58:50 +0800 Subject: [PATCH 103/139] output OP_FCONV_TO_U8 --- src/mono/mono/mini/mini-riscv.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 93fc27f10915f..6b1a1e14473f6 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -4834,6 +4834,11 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fcvt_lu_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } + case OP_FCONV_TO_U8: { + g_assert (riscv_stdext_f); + riscv_fcvt_lu_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); + break; + } case OP_RCONV_TO_I4: { g_assert (riscv_stdext_f); riscv_fcvt_w_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); From aff9c577806d8521a74719b22f1bda319819eede Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 15:59:32 +0800 Subject: [PATCH 104/139] long_xor_imm --- src/mono/mono/mini/cpu-riscv64.mdesc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index b00d242572a2e..74b206f1133a6 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -207,7 +207,7 @@ long_and: dest:i src1:i src2:i len:4 long_and_imm: dest:i src1:i len:4 long_or: dest:i src1:i src2:i len:4 long_xor: dest:i src1:i src2:i len:4 -int_xor_imm: dest:i src1:i len:4 +long_xor_imm: dest:i src1:i len:4 long_or_imm: dest:i src1:i len:4 long_shl: dest:i src1:i src2:i len:4 long_shl_imm: dest:i src1:i len:4 From a90fc11a880275772d6ae521b7223ecb5ea232de Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 19:03:34 +0800 Subject: [PATCH 105/139] move throw ip to RISCV_RA from RISCV_T0 --- src/mono/mono/mini/mini-riscv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 6b1a1e14473f6..645f6769d573e 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3943,7 +3943,7 @@ mono_riscv_emit_call (MonoCompile *cfg, guint8 *code, MonoJumpInfoType patch_typ static guint8 * mono_riscv_emit_branch_exc (MonoCompile *cfg, guint8 *code, int opcode, int sreg1, int sreg2, const char *exc_name) { - riscv_auipc (code, RISCV_T0, 0); + riscv_auipc (code, RISCV_RA, 0); switch (opcode) { case OP_RISCV_EXC_BEQ: riscv_bne (code, sreg1, sreg2, 8); @@ -4834,7 +4834,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fcvt_lu_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } - case OP_FCONV_TO_U8: { + case OP_RCONV_TO_U8: { g_assert (riscv_stdext_f); riscv_fcvt_lu_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; @@ -5241,7 +5241,7 @@ mono_arch_emit_exceptions (MonoCompile *cfg) exc_class = mono_class_load_from_name (mono_defaults.corlib, "System", ji->data.name); code = mono_riscv_emit_imm (code, RISCV_A0, m_class_get_type_token (exc_class) - MONO_TOKEN_TYPE_DEF); /* A1 = throw ip */ - riscv_addi (code, RISCV_A1, RISCV_T0, 0); + riscv_addi (code, RISCV_A1, RISCV_RA, 0); /* Branch to the corlib exception throwing trampoline */ ji->ip.i = code - cfg->native_code; ji->type = MONO_PATCH_INFO_JIT_ICALL_ID; From 79e8c7d0a04e94021e4d2b4ba08039df36e306ac Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 20:47:15 +0800 Subject: [PATCH 106/139] fix Div By Zero check of OP_{F|R}DIV --- src/mono/mono/mini/mini-riscv.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 645f6769d573e..deacef6b9c7fd 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -4521,14 +4521,14 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) if (riscv_stdext_d) { riscv_fmv_d_x (code, RISCV_FT0, RISCV_ZERO); riscv_feq_d (code, RISCV_T0, ins->sreg2, RISCV_FT0); - code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BEQ, RISCV_T0, RISCV_ZERO, + code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BNE, RISCV_T0, RISCV_ZERO, "DivideByZeroException"); riscv_fdiv_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); } else { NOT_IMPLEMENTED; riscv_fmv_w_x (code, RISCV_FT0, RISCV_ZERO); riscv_feq_s (code, RISCV_T0, ins->sreg2, RISCV_FT0); - code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BEQ, RISCV_T0, RISCV_ZERO, + code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BNE, RISCV_T0, RISCV_ZERO, "DivideByZeroException"); riscv_fdiv_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); } @@ -4882,7 +4882,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fmv_w_x (code, RISCV_FT0, RISCV_ZERO); riscv_feq_s (code, RISCV_T0, ins->sreg2, RISCV_FT0); - code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BEQ, RISCV_T0, RISCV_ZERO, + code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BNE, RISCV_T0, RISCV_ZERO, "DivideByZeroException"); riscv_fdiv_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); break; From e8dbc860f1d4180987236051fd63a0dd0754f046 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 21:04:39 +0800 Subject: [PATCH 107/139] OP_{F|R}MOVE --- src/mono/mono/mini/mini-riscv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index deacef6b9c7fd..406f02ae826e6 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1814,6 +1814,8 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) { switch (ins->opcode) { case OP_CKFINITE: + case OP_FMOVE: + case OP_RMOVE: case OP_IADD: case OP_LADD: case OP_RADD: From f7637f6ef9a62707e4de18e118faef479ab69f35 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 22:52:25 +0800 Subject: [PATCH 108/139] lowering _IMM to _REG --- src/mono/mono/mini/mini-riscv.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 406f02ae826e6..b181677bb9f3c 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2340,19 +2340,10 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_LOR: case OP_ISHL: case OP_LSHL: - case OP_SHL_IMM: - case OP_ISHL_IMM: - case OP_LSHL_IMM: case OP_ISHR: case OP_ISHR_UN: - case OP_SHR_IMM: - case OP_ISHR_IMM: - case OP_SHR_UN_IMM: - case OP_ISHR_UN_IMM: case OP_LSHR: case OP_LSHR_UN: - case OP_LSHR_IMM: - case OP_LSHR_UN_IMM: case OP_LOCALLOC: /* skip dummy IL */ @@ -3234,7 +3225,16 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_XOR_IMM: case OP_IXOR_IMM: case OP_LXOR_IMM: - if (!RISCV_VALID_I_IMM (ins->inst_imm)) + case OP_SHL_IMM: + case OP_ISHL_IMM: + case OP_LSHL_IMM: + case OP_LSHR_IMM: + case OP_LSHR_UN_IMM: + case OP_SHR_IMM: + case OP_ISHR_IMM: + case OP_SHR_UN_IMM: + case OP_ISHR_UN_IMM: + if (!RISCV_VALID_LS_AMOUNT (ins->inst_imm)) mono_decompose_op_imm (cfg, bb, ins); break; case OP_INOT: From dc723b431baeaf140a742d0e3a213b225ee491e0 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Thu, 21 Dec 2023 23:10:42 +0800 Subject: [PATCH 109/139] OP_ATOMIC LOAD & STORE --- src/mono/mono/mini/cpu-riscv64.mdesc | 10 +++++++- src/mono/mono/mini/mini-riscv.c | 36 ++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 6 deletions(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 74b206f1133a6..384f04d442090 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -103,12 +103,20 @@ loadr8_membase: dest:f src1:b len:24 memory_barrier: len:4 atomic_add_i4: dest:i src1:i src2:i len:4 atomic_add_i8: dest:i src1:i src2:i len:4 +atomic_store_i1: dest:b src1:i len:8 atomic_store_u1: dest:b src1:i len:8 +atomic_store_i2: dest:b src1:i len:8 +atomic_store_u2: dest:b src1:i len:8 atomic_store_i4: dest:b src1:i len:8 -atomic_store_u8: dest:b src1:i len:8 +atomic_store_u4: dest:b src1:i len:8 atomic_store_i8: dest:b src1:i len:8 +atomic_store_u8: dest:b src1:i len:8 +atomic_load_i1: dest:b src1:i len:12 atomic_load_u1: dest:b src1:i len:12 +atomic_load_i2: dest:b src1:i len:12 +atomic_load_u2: dest:b src1:i len:12 atomic_load_i4: dest:b src1:i len:12 +atomic_load_u4: dest:b src1:i len:12 atomic_load_i8: dest:b src1:i len:12 atomic_load_u8: dest:b src1:i len:12 atomic_cas_i4: dest:i src1:i src2:i src3:i len:24 diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index b181677bb9f3c..eab78d90d9c4d 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2373,12 +2373,20 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) /* Atomic Ext */ case OP_MEMORY_BARRIER: case OP_ATOMIC_ADD_I4: + case OP_ATOMIC_STORE_I1: case OP_ATOMIC_STORE_U1: + case OP_ATOMIC_STORE_I2: + case OP_ATOMIC_STORE_U2: case OP_ATOMIC_STORE_I4: + case OP_ATOMIC_STORE_U4: case OP_ATOMIC_STORE_I8: case OP_ATOMIC_STORE_U8: + case OP_ATOMIC_LOAD_I1: case OP_ATOMIC_LOAD_U1: + case OP_ATOMIC_LOAD_I2: + case OP_ATOMIC_LOAD_U2: case OP_ATOMIC_LOAD_I4: + case OP_ATOMIC_LOAD_U4: case OP_ATOMIC_LOAD_I8: case OP_ATOMIC_LOAD_U8: case OP_ATOMIC_CAS_I4: @@ -4695,18 +4703,27 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_ATOMIC_ADD_I8: riscv_amoadd_d (code, RISCV_ORDER_ALL, ins->dreg, ins->sreg2, ins->sreg1); break; - case OP_ATOMIC_LOAD_I4: { + case OP_ATOMIC_LOAD_I1: + case OP_ATOMIC_LOAD_U1: { riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_MEM); - code = mono_riscv_emit_load (code, ins->dreg, ins->sreg1, ins->inst_offset, 4); + code = mono_riscv_emit_load (code, ins->dreg, ins->sreg1, ins->inst_offset, 1); riscv_fence (code, RISCV_FENCE_R, RISCV_FENCE_MEM); break; } - case OP_ATOMIC_LOAD_U1: { + case OP_ATOMIC_LOAD_U2: + case OP_ATOMIC_LOAD_I2: { riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_MEM); - code = mono_riscv_emit_load (code, ins->dreg, ins->sreg1, ins->inst_offset, 1); + code = mono_riscv_emit_load (code, ins->dreg, ins->sreg1, ins->inst_offset, 2); + riscv_fence (code, RISCV_FENCE_R, RISCV_FENCE_MEM); + } + case OP_ATOMIC_LOAD_I4: + case OP_ATOMIC_LOAD_U4: { + riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_MEM); + code = mono_riscv_emit_load (code, ins->dreg, ins->sreg1, ins->inst_offset, 4); riscv_fence (code, RISCV_FENCE_R, RISCV_FENCE_MEM); break; } + case OP_ATOMIC_STORE_I1: case OP_ATOMIC_STORE_U1: { riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_W); code = mono_riscv_emit_store (code, ins->sreg1, ins->inst_destbasereg, ins->inst_offset, 1); @@ -4714,7 +4731,16 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_MEM); break; } - case OP_ATOMIC_STORE_I4: { + case OP_ATOMIC_STORE_I2: + case OP_ATOMIC_STORE_U2: { + riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_W); + code = mono_riscv_emit_store (code, ins->sreg1, ins->inst_destbasereg, ins->inst_offset, 2); + if (ins->backend.memory_barrier_kind == MONO_MEMORY_BARRIER_SEQ) + riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_MEM); + break; + } + case OP_ATOMIC_STORE_I4: + case OP_ATOMIC_STORE_U4: { riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_W); code = mono_riscv_emit_store (code, ins->sreg1, ins->inst_destbasereg, ins->inst_offset, 4); if (ins->backend.memory_barrier_kind == MONO_MEMORY_BARRIER_SEQ) From c7b88cf229fa5d529917711823bfe32ab1f08ed4 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Fri, 22 Dec 2023 12:25:52 +0800 Subject: [PATCH 110/139] extend thunk size when mono_riscv_emit_branch_exc remove Devide by Zero check for {F|R}_DIV --- src/mono/mono/mini/mini-riscv.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index eab78d90d9c4d..1fbd81908d2c0 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3975,6 +3975,7 @@ mono_riscv_emit_branch_exc (MonoCompile *cfg, guint8 *code, int opcode, int sreg NOT_IMPLEMENTED; } mono_add_patch_info_rel (cfg, code - cfg->native_code, MONO_PATCH_INFO_EXC, exc_name, MONO_R_RISCV_JAL); + cfg->thunk_area += THUNK_SIZE; riscv_jal (code, RISCV_ZERO, 0); return code; } @@ -4529,17 +4530,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_FDIV: g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) { - riscv_fmv_d_x (code, RISCV_FT0, RISCV_ZERO); - riscv_feq_d (code, RISCV_T0, ins->sreg2, RISCV_FT0); - code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BNE, RISCV_T0, RISCV_ZERO, - "DivideByZeroException"); riscv_fdiv_d (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); } else { NOT_IMPLEMENTED; - riscv_fmv_w_x (code, RISCV_FT0, RISCV_ZERO); - riscv_feq_s (code, RISCV_T0, ins->sreg2, RISCV_FT0); - code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BNE, RISCV_T0, RISCV_ZERO, - "DivideByZeroException"); riscv_fdiv_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); } break; @@ -4901,17 +4894,6 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) } case OP_RDIV: { g_assert (riscv_stdext_f); - /** - * insert inst for the case Divide By 0 - * fmv.w.x ft0, zero - * feq.s t0, sreg2, ft0 - * beqz t0, zero - */ - riscv_fmv_w_x (code, RISCV_FT0, RISCV_ZERO); - riscv_feq_s (code, RISCV_T0, ins->sreg2, RISCV_FT0); - - code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BNE, RISCV_T0, RISCV_ZERO, - "DivideByZeroException"); riscv_fdiv_s (code, RISCV_ROUND_DY, ins->dreg, ins->sreg1, ins->sreg2); break; } @@ -5038,6 +5020,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) } else{ mono_add_patch_info_rel (cfg, GPTRDIFF_TO_INT (code - cfg->native_code), MONO_PATCH_INFO_METHOD_JUMP, call->method, MONO_R_RISCV_JAL); + cfg->thunk_area += THUNK_SIZE; riscv_jal (code, RISCV_ZERO, 0); } break; From e74e169236c2d765c2ba6c8bef32ae8374a5b41a Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Fri, 22 Dec 2023 16:46:22 +0800 Subject: [PATCH 111/139] fix lowering OP_INEG/OP_LNEG --- src/mono/mono/mini/mini-riscv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 1fbd81908d2c0..fbb06f8705b60 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3085,7 +3085,10 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) /* Math */ case OP_INEG: case OP_LNEG: - ins->opcode = OP_ISUB; + if (ins->opcode == OP_INEG) + ins->opcode = OP_ISUB; + else + ins->opcode = OP_LSUB; ins->sreg2 = ins->sreg1; ins->sreg1 = RISCV_ZERO; break; From 6d63c4c8c180d689e6a365e5b0c246283a983c45 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Fri, 22 Dec 2023 17:02:03 +0800 Subject: [PATCH 112/139] lowering OP_IADD_IMM or OP_LADD_IMM by OP_ICEQ or OP_LCEQ --- src/mono/mono/mini/mini-riscv.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index fbb06f8705b60..a670a07dad715 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2862,7 +2862,10 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) if (next_ins->opcode == OP_LCEQ || next_ins->opcode == OP_ICEQ) { if (RISCV_VALID_I_IMM (ins->inst_imm)) { // compare rs1, imm; lceq rd => addi rs2, rs1, -imm; sltiu rd, rs2, 1 - ins->opcode = OP_ADD_IMM; + if (next_ins->opcode == OP_ICEQ) + ins->opcode = OP_IADD_IMM; + else + ins->opcode = OP_LADD_IMM; ins->dreg = mono_alloc_ireg (cfg); ins->inst_imm = -ins->inst_imm; @@ -2875,7 +2878,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) if (next_ins->opcode == OP_ICNEQ) { if (RISCV_VALID_I_IMM (ins->inst_imm)) { // compare rs1, imm; lcneq rd => addi rs2, rs1, -imm; sltu rd, X0, rs2 - ins->opcode = OP_ADD_IMM; + ins->opcode = OP_IADD_IMM; ins->dreg = mono_alloc_ireg (cfg); ins->inst_imm = -ins->inst_imm; @@ -4456,8 +4459,12 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_LADD: riscv_add (code, ins->dreg, ins->sreg1, ins->sreg2); break; - case OP_ADD_IMM: case OP_IADD_IMM: +#ifdef TARGET_RISCV64 + riscv_addiw (code, ins->dreg, ins->sreg1, ins->inst_imm); + break; +#endif + case OP_ADD_IMM: case OP_LADD_IMM: riscv_addi (code, ins->dreg, ins->sreg1, ins->inst_imm); break; From 8a3b57c2af5c9e7f2dc6b68ad2c9cb2df6b6089b Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Fri, 22 Dec 2023 23:53:19 +0800 Subject: [PATCH 113/139] casting return value to uint8 --- src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il b/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il index fc330a956664e..b5effff3389c6 100644 --- a/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il +++ b/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il @@ -126,6 +126,7 @@ L1: ldarg.s 0x1 cgt shr.un neg + conv.u1 ret } // end of method DevDiv_545500:Test From 6091443f604a6fdf0c71ed45f106063defa948eb Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 23 Dec 2023 11:08:31 +0800 Subject: [PATCH 114/139] for test --- src/tests/JIT/Regression/Regression_3.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/JIT/Regression/Regression_3.csproj b/src/tests/JIT/Regression/Regression_3.csproj index 4eafe2b2450fb..29ba8a3b09e3e 100644 --- a/src/tests/JIT/Regression/Regression_3.csproj +++ b/src/tests/JIT/Regression/Regression_3.csproj @@ -1,6 +1,6 @@ - + From c6e52f446eccfb69c9e01b3cfa97180862d92dec Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 23 Dec 2023 17:34:34 +0800 Subject: [PATCH 115/139] define MONO_ARCH_LLVM_SUPPORTED to insert extra truncate inst --- src/mono/mono/mini/mini-riscv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.h b/src/mono/mono/mini/mini-riscv.h index 57ec36ea0e3e1..3706d9881e3c4 100644 --- a/src/mono/mono/mini/mini-riscv.h +++ b/src/mono/mono/mini/mini-riscv.h @@ -166,7 +166,7 @@ extern gboolean riscv_stdext_a, riscv_stdext_b, riscv_stdext_c, riscv_stdext_d, #define MONO_ARCH_GSHARED_SUPPORTED (1) #define MONO_ARCH_INTERPRETER_SUPPORTED (1) //#define MONO_ARCH_AOT_SUPPORTED (1) -//#define MONO_ARCH_LLVM_SUPPORTED (1) +#define MONO_ARCH_LLVM_SUPPORTED (1) #define MONO_ARCH_SOFT_DEBUG_SUPPORTED (1) #define MONO_ARCH_FLOAT32_SUPPORTED (1) From 61a99b916336fa71f6413784ff66610e6cec1fce Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 23 Dec 2023 17:37:13 +0800 Subject: [PATCH 116/139] reset test case --- src/tests/JIT/Regression/Regression_3.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/JIT/Regression/Regression_3.csproj b/src/tests/JIT/Regression/Regression_3.csproj index 29ba8a3b09e3e..93891ff7b3074 100644 --- a/src/tests/JIT/Regression/Regression_3.csproj +++ b/src/tests/JIT/Regression/Regression_3.csproj @@ -1,8 +1,8 @@ - + - + \ No newline at end of file From 400052ac195dc5861f7ca07add302dbdff028812 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 23 Dec 2023 22:15:58 +0800 Subject: [PATCH 117/139] fix case OP_COND_EXC_C after OP_ADDCC --- src/mono/mono/mini/mini-riscv.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index a670a07dad715..af56c83316f97 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3174,8 +3174,14 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) MonoInst *branch_ins = next_ins; if (branch_ins) { - if (branch_ins->opcode == OP_COND_EXC_C || branch_ins->opcode == OP_COND_EXC_IC || - branch_ins->opcode == OP_COND_EXC_OV || branch_ins->opcode == OP_COND_EXC_IOV) { + if (branch_ins->opcode == OP_COND_EXC_C || branch_ins->opcode == OP_COND_EXC_IC){ + // bltu rd, rs1, overflow + + branch_ins->opcode = OP_RISCV_EXC_BLTU; + branch_ins->sreg1 = ins->dreg; + branch_ins->sreg2 = ins->sreg1; + } + else if (branch_ins->opcode == OP_COND_EXC_OV || branch_ins->opcode == OP_COND_EXC_IOV) { // bne t3, t4, overflow branch_ins->opcode = OP_RISCV_EXC_BNE; branch_ins->sreg1 = mono_alloc_ireg (cfg); From 115b9bdbe4615d6ed57aca25de15502f9c1c251e Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sun, 24 Dec 2023 17:43:43 +0800 Subject: [PATCH 118/139] use OP_RISCV_R|F BNAN help for R|F compare --- src/mono/mono/arch/riscv/riscv-codegen.h | 15 +++++++++ src/mono/mono/mini/cpu-riscv64.mdesc | 2 ++ src/mono/mono/mini/mini-ops.h | 2 ++ src/mono/mono/mini/mini-riscv.c | 39 +++++++++++++++++++++++- 4 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/arch/riscv/riscv-codegen.h b/src/mono/mono/arch/riscv/riscv-codegen.h index 054c0b0744c4e..389ef465e50a7 100644 --- a/src/mono/mono/arch/riscv/riscv-codegen.h +++ b/src/mono/mono/arch/riscv/riscv-codegen.h @@ -252,6 +252,21 @@ enum { RISCV_ROUND_DY = 0b111, // Use current rounding mode in the FRM CSR. }; +enum { + RISCV_FCLASS_NINF = 0b1 << 0, // Negative infinity. + RISCV_FCLASS_NN = 0b1 << 1, // Negative normal. + RISCV_FCLASS_ND = 0b1 << 2, // Negative denormal. + RISCV_FCLASS_NZ = 0b1 << 3, // Negative zero. + RISCV_FCLASS_PZ = 0b1 << 4, // Positive zero. + RISCV_FCLASS_PD = 0b1 << 5, // Positive denormal. + RISCV_FCLASS_PN = 0b1 << 6, // Positive normal. + RISCV_FCLASS_PINF = 0b1 << 7, // Positive infinity. + RISCV_FCLASS_SNAN = 0b1 << 8, // Signalling NaN. + RISCV_FCLASS_QNAN = 0b1 << 9, // Quiet NaN. + RISCV_FCLASS_INF = RISCV_FCLASS_NINF | RISCV_FCLASS_PINF, + RISCV_FCLASS_NAN = RISCV_FCLASS_SNAN | RISCV_FCLASS_QNAN, +}; + #define _riscv_emit(p, insn) \ do { \ *(guint32 *) (p) = (insn); \ diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 384f04d442090..dadd203646e6c 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -226,6 +226,8 @@ long_shr_un_imm: dest:i src1:i len:4 riscv_setfreg_r4: dest:f src1:f len:4 +riscv_float_bnan: src1:f len:16 +riscv_r4_bnan: src1:f len:16 riscv_beq: src1:i src2:i len:8 riscv_bne: src1:i src2:i len:8 diff --git a/src/mono/mono/mini/mini-ops.h b/src/mono/mono/mini/mini-ops.h index 17dbc05d8763a..ccdc1726a3025 100644 --- a/src/mono/mono/mini/mini-ops.h +++ b/src/mono/mono/mini/mini-ops.h @@ -1889,6 +1889,8 @@ MINI_OP(OP_RISCV_BGE, "riscv_bge", NONE, IREG, IREG) MINI_OP(OP_RISCV_BGEU, "riscv_bgeu", NONE, IREG, IREG) MINI_OP(OP_RISCV_BLT, "riscv_blt", NONE, IREG, IREG) MINI_OP(OP_RISCV_BLTU, "riscv_bltu", NONE, IREG, IREG) +MINI_OP(OP_RISCV_RBNAN, "riscv_r4_bnan", NONE, FREG, NONE) +MINI_OP(OP_RISCV_FBNAN, "riscv_float_bnan", NONE, FREG, NONE) MINI_OP(OP_RISCV_ADDIW, "riscv_addiw", IREG, IREG, NONE) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index af56c83316f97..ba541d64012b7 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2568,6 +2568,15 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) } case OP_RCOMPARE: { if (next_ins) { + // insert two OP_RISCV_FBNAN in case unordered compare + NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_RBNAN); + temp->sreg1 = ins->sreg1; + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_true_bb = next_ins->inst_true_bb; + NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_RBNAN); + temp->sreg1 = ins->sreg2; + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_true_bb = next_ins->inst_true_bb; if (next_ins->opcode == OP_FBLT || next_ins->opcode == OP_FBLT_UN) { ins->opcode = OP_RCLT; ins->dreg = mono_alloc_ireg (cfg); @@ -2633,6 +2642,15 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) } case OP_FCOMPARE: { if (next_ins) { + // insert two OP_RISCV_FBNAN in case unordered compare + NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_FBNAN); + temp->sreg1 = ins->sreg1; + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_true_bb = next_ins->inst_true_bb; + NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_FBNAN); + temp->sreg1 = ins->sreg2; + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_true_bb = next_ins->inst_true_bb; if (next_ins->opcode == OP_FBLT || next_ins->opcode == OP_FBLT_UN) { ins->opcode = OP_FCLT; ins->dreg = mono_alloc_ireg (cfg); @@ -4356,7 +4374,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fclass_d (code, RISCV_T0, ins->sreg1); else riscv_fclass_s (code, RISCV_T0, ins->sreg1); - riscv_andi (code, RISCV_T0, RISCV_T0, 0b0001111110); + + riscv_andi (code, RISCV_T0, RISCV_T0, ~(RISCV_FCLASS_INF | RISCV_FCLASS_NAN)); code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BEQ, RISCV_T0, RISCV_ZERO, "ArithmeticException"); } @@ -5141,6 +5160,24 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) MONO_R_RISCV_IMM); code = mono_riscv_emit_imm (code, ins->dreg, 0xffffffff); break; + case OP_RISCV_FBNAN: + // fclass.d T0, rs1; andi T0, T0, RISCV_FCLASS_NAN; bne T0, zero, target + riscv_fclass_d (code, RISCV_T0, ins->sreg1); + riscv_andi (code, RISCV_T0, RISCV_T0, RISCV_FCLASS_NAN); + mono_add_patch_info_rel (cfg, (code - cfg->native_code), MONO_PATCH_INFO_BB, ins->inst_true_bb, + MONO_R_RISCV_BNE); + riscv_bne (code, RISCV_T0, RISCV_ZERO, 0); + code = mono_riscv_emit_nop (code); + break; + case OP_RISCV_RBNAN: + // fclass.s T0, rs1; andi T0, T0, RISCV_FCLASS_NAN; bne T0, zero, target + riscv_fclass_s (code, RISCV_T0, ins->sreg1); + riscv_andi (code, RISCV_T0, RISCV_T0, RISCV_FCLASS_NAN); + mono_add_patch_info_rel (cfg, (code - cfg->native_code), MONO_PATCH_INFO_BB, ins->inst_true_bb, + MONO_R_RISCV_BNE); + riscv_bne (code, RISCV_T0, RISCV_ZERO, 0); + code = mono_riscv_emit_nop (code); + break; case OP_RISCV_EXC_BNE: case OP_RISCV_EXC_BEQ: case OP_RISCV_EXC_BGEU: From 4e05963775d7f3f12d402c88a16aed64496ddf8c Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sun, 24 Dec 2023 17:56:54 +0800 Subject: [PATCH 119/139] dont emit OP_RISCV_RBNAN for FBEQ&FBNE --- src/mono/mono/mini/mini-riscv.c | 40 +++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index ba541d64012b7..99697e16083dd 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2569,14 +2569,17 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_RCOMPARE: { if (next_ins) { // insert two OP_RISCV_FBNAN in case unordered compare - NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_RBNAN); - temp->sreg1 = ins->sreg1; - temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); - temp->inst_true_bb = next_ins->inst_true_bb; - NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_RBNAN); - temp->sreg1 = ins->sreg2; - temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); - temp->inst_true_bb = next_ins->inst_true_bb; + if (next_ins->opcode != OP_FBEQ && next_ins->opcode != OP_FBNE_UN){ + NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_RBNAN); + temp->sreg1 = ins->sreg1; + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_true_bb = next_ins->inst_true_bb; + NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_RBNAN); + temp->sreg1 = ins->sreg2; + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_true_bb = next_ins->inst_true_bb; + } + if (next_ins->opcode == OP_FBLT || next_ins->opcode == OP_FBLT_UN) { ins->opcode = OP_RCLT; ins->dreg = mono_alloc_ireg (cfg); @@ -2642,15 +2645,18 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) } case OP_FCOMPARE: { if (next_ins) { - // insert two OP_RISCV_FBNAN in case unordered compare - NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_FBNAN); - temp->sreg1 = ins->sreg1; - temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); - temp->inst_true_bb = next_ins->inst_true_bb; - NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_FBNAN); - temp->sreg1 = ins->sreg2; - temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); - temp->inst_true_bb = next_ins->inst_true_bb; + if (next_ins->opcode != OP_FBEQ && next_ins->opcode != OP_FBNE_UN){ + // insert two OP_RISCV_FBNAN in case unordered compare + NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_FBNAN); + temp->sreg1 = ins->sreg1; + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_true_bb = next_ins->inst_true_bb; + NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_FBNAN); + temp->sreg1 = ins->sreg2; + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_true_bb = next_ins->inst_true_bb; + } + if (next_ins->opcode == OP_FBLT || next_ins->opcode == OP_FBLT_UN) { ins->opcode = OP_FCLT; ins->dreg = mono_alloc_ireg (cfg); From 09eec19044c9bc0a01daf365f9f13307703042b2 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sun, 24 Dec 2023 18:20:59 +0800 Subject: [PATCH 120/139] process all unorder operattions --- src/mono/mono/mini/mini-riscv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 99697e16083dd..b812a1ff0278a 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2569,7 +2569,9 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_RCOMPARE: { if (next_ins) { // insert two OP_RISCV_FBNAN in case unordered compare - if (next_ins->opcode != OP_FBEQ && next_ins->opcode != OP_FBNE_UN){ + if (next_ins->opcode == OP_FBLT_UN || next_ins->opcode == OP_FBGT_UN || + next_ins->opcode == OP_FBGE_UN || next_ins->opcode == OP_FBLE_UN || + next_ins->opcode == OP_FBNE_UN){ NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_RBNAN); temp->sreg1 = ins->sreg1; temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); @@ -2645,7 +2647,9 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) } case OP_FCOMPARE: { if (next_ins) { - if (next_ins->opcode != OP_FBEQ && next_ins->opcode != OP_FBNE_UN){ + if (next_ins->opcode == OP_FBLT_UN || next_ins->opcode == OP_FBGT_UN || + next_ins->opcode == OP_FBGE_UN || next_ins->opcode == OP_FBLE_UN || + next_ins->opcode == OP_FBNE_UN){ // insert two OP_RISCV_FBNAN in case unordered compare NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_FBNAN); temp->sreg1 = ins->sreg1; From f377e84d7f2d90a05c560460069e351099ab4ea1 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Mon, 25 Dec 2023 12:03:42 +0800 Subject: [PATCH 121/139] use MicroDef MONO_ARCH_EXC_ADDR_REG for throw exception --- src/mono/mono/mini/mini-riscv.c | 4 ++-- src/mono/mono/mini/mini-riscv.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index b812a1ff0278a..5676e4e434370 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3993,7 +3993,7 @@ mono_riscv_emit_call (MonoCompile *cfg, guint8 *code, MonoJumpInfoType patch_typ static guint8 * mono_riscv_emit_branch_exc (MonoCompile *cfg, guint8 *code, int opcode, int sreg1, int sreg2, const char *exc_name) { - riscv_auipc (code, RISCV_RA, 0); + riscv_auipc (code, MONO_ARCH_EXC_ADDR_REG, 0); switch (opcode) { case OP_RISCV_EXC_BEQ: riscv_bne (code, sreg1, sreg2, 8); @@ -5315,7 +5315,7 @@ mono_arch_emit_exceptions (MonoCompile *cfg) exc_class = mono_class_load_from_name (mono_defaults.corlib, "System", ji->data.name); code = mono_riscv_emit_imm (code, RISCV_A0, m_class_get_type_token (exc_class) - MONO_TOKEN_TYPE_DEF); /* A1 = throw ip */ - riscv_addi (code, RISCV_A1, RISCV_RA, 0); + riscv_addi (code, RISCV_A1, MONO_ARCH_EXC_ADDR_REG, 0); /* Branch to the corlib exception throwing trampoline */ ji->ip.i = code - cfg->native_code; ji->type = MONO_PATCH_INFO_JIT_ICALL_ID; diff --git a/src/mono/mono/mini/mini-riscv.h b/src/mono/mono/mini/mini-riscv.h index 3706d9881e3c4..f791cc5b388be 100644 --- a/src/mono/mono/mini/mini-riscv.h +++ b/src/mono/mono/mini/mini-riscv.h @@ -62,6 +62,7 @@ extern gboolean riscv_stdext_a, riscv_stdext_b, riscv_stdext_c, riscv_stdext_d, #define MONO_ARCH_CALLEE_REGS (0b11110000000000111111110000000000) #define MONO_ARCH_CALLEE_SAVED_REGS (0b00001111111111000000001100000000) #define MONO_ARCH_IS_CALLEE_SAVED_REG(reg) (MONO_ARCH_CALLEE_SAVED_REGS & (1 << (reg))) +#define MONO_ARCH_EXC_ADDR_REG (RISCV_T1) /** * callee saved regs + sp @@ -111,7 +112,7 @@ extern gboolean riscv_stdext_a, riscv_stdext_b, riscv_stdext_c, riscv_stdext_d, #endif -#define MONO_ARCH_RGCTX_REG (RISCV_T6) +#define MONO_ARCH_RGCTX_REG (RISCV_T2) #define MONO_ARCH_IMT_REG MONO_ARCH_RGCTX_REG #define MONO_ARCH_VTABLE_REG (RISCV_A0) From ef63c61c948af1a42813a43e8e47acdc060d756a Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Mon, 25 Dec 2023 19:40:05 +0800 Subject: [PATCH 122/139] make pc point to EXC_BRANCH inst --- src/mono/mono/mini/cpu-riscv64.mdesc | 10 +++++----- src/mono/mono/mini/exceptions-riscv.c | 2 +- src/mono/mono/mini/mini-riscv.c | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index dadd203646e6c..5efee20667ef5 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -235,11 +235,11 @@ riscv_bge: src1:i src2:i len:8 riscv_bgeu: src1:i src2:i len:8 riscv_blt: src1:i src2:i len:8 riscv_bltu: src1:i src2:i len:8 -riscv_exc_beq: src1:i src2:i len:12 -riscv_exc_bne: src1:i src2:i len:12 -riscv_exc_bgeu: src1:i src2:i len:12 -riscv_exc_blt: src1:i src2:i len:12 -riscv_exc_bltu: src1:i src2:i len:12 +riscv_exc_beq: src1:i src2:i len:16 +riscv_exc_bne: src1:i src2:i len:16 +riscv_exc_bgeu: src1:i src2:i len:16 +riscv_exc_blt: src1:i src2:i len:16 +riscv_exc_bltu: src1:i src2:i len:16 riscv_slt: dest:i src1:i src2:i len:4 riscv_sltu: dest:i src1:i src2:i len:4 riscv_slti: dest:i src1:i len:4 diff --git a/src/mono/mono/mini/exceptions-riscv.c b/src/mono/mono/mini/exceptions-riscv.c index d9a888dd89860..40f65789fb556 100644 --- a/src/mono/mono/mini/exceptions-riscv.c +++ b/src/mono/mono/mini/exceptions-riscv.c @@ -83,7 +83,7 @@ mono_riscv_throw_exception (gpointer arg, host_mgreg_t pc, host_mgreg_t *int_reg } /* Adjust pc so it points into the call instruction */ - pc -= 4; + pc--; /* Initialize a ctx based on the arguments */ memset (&ctx, 0, sizeof (MonoContext)); diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 5676e4e434370..5f714db9d7176 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3662,9 +3662,9 @@ mono_riscv_emit_load_regarray (guint8 *code, guint64 regs, int basereg, int offs g_assert (basereg != RISCV_SP); if (!RISCV_VALID_S_IMM (offset)) { - code = mono_riscv_emit_imm (code, RISCV_T6, offset); - riscv_add (code, RISCV_T6, basereg, RISCV_T6); - basereg = RISCV_T6; + code = mono_riscv_emit_imm (code, RISCV_T0, offset); + riscv_add (code, RISCV_T0, basereg, RISCV_T0); + basereg = RISCV_T0; offset = 0; } @@ -3694,9 +3694,9 @@ mono_riscv_emit_store_regarray (guint8 *code, guint64 regs, int basereg, int off g_assert (basereg != RISCV_SP); if (!RISCV_VALID_S_IMM (offset)) { - code = mono_riscv_emit_imm (code, RISCV_T6, offset); - riscv_add (code, RISCV_T6, basereg, RISCV_T6); - basereg = RISCV_T6; + code = mono_riscv_emit_imm (code, RISCV_T0, offset); + riscv_add (code, RISCV_T0, basereg, RISCV_T0); + basereg = RISCV_T0; offset = 0; } @@ -3725,9 +3725,9 @@ mono_riscv_emit_load_stack (guint8 *code, guint64 regs, int basereg, int offset, g_assert (basereg != RISCV_SP); if (!RISCV_VALID_S_IMM (offset)) { - code = mono_riscv_emit_imm (code, RISCV_T6, offset); - riscv_add (code, RISCV_T6, basereg, RISCV_T6); - basereg = RISCV_T6; + code = mono_riscv_emit_imm (code, RISCV_T0, offset); + riscv_add (code, RISCV_T0, basereg, RISCV_T0); + basereg = RISCV_T0; offset = 0; } @@ -3994,6 +3994,7 @@ static guint8 * mono_riscv_emit_branch_exc (MonoCompile *cfg, guint8 *code, int opcode, int sreg1, int sreg2, const char *exc_name) { riscv_auipc (code, MONO_ARCH_EXC_ADDR_REG, 0); + riscv_addi (code, MONO_ARCH_EXC_ADDR_REG, MONO_ARCH_EXC_ADDR_REG,8); switch (opcode) { case OP_RISCV_EXC_BEQ: riscv_bne (code, sreg1, sreg2, 8); From 641208e821ebbdf5ce7c6b295758743ba54a6569 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Mon, 25 Dec 2023 19:45:50 +0800 Subject: [PATCH 123/139] fix length of ckfinite --- src/mono/mono/mini/cpu-riscv64.mdesc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/cpu-riscv64.mdesc b/src/mono/mono/mini/cpu-riscv64.mdesc index 5efee20667ef5..eba087a9b5901 100644 --- a/src/mono/mono/mini/cpu-riscv64.mdesc +++ b/src/mono/mono/mini/cpu-riscv64.mdesc @@ -45,7 +45,7 @@ endfilter: src1:i len:32 localloc: dest:i src1:i len:52 localloc_imm: dest:i len:28 generic_class_init: src1:a len:12 clob:c -ckfinite: dest:f src1:f len:24 +ckfinite: dest:f src1:f len:28 break: len:4 throw: src1:i len:4 From 4ccd89026bfaca65c974fbce07cd2d272c722c3b Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 26 Dec 2023 17:27:27 +0800 Subject: [PATCH 124/139] fix OP_I8const and OP_ICONST --- src/mono/mono/mini/mini-riscv.c | 90 ++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 30 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 5f714db9d7176..89794d4ded093 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1520,9 +1520,9 @@ emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call, CallInfo *cinfo) memcpy (tmp_sig->params, call->signature->params + call->signature->sentinelpos, tmp_sig->param_count * sizeof (MonoType *)); - MONO_INST_NEW (cfg, sig_arg, OP_ICONST); + MONO_INST_NEW (cfg, sig_arg, OP_I8CONST); sig_arg->dreg = mono_alloc_ireg (cfg); - sig_arg->inst_p0 = tmp_sig; + sig_arg->inst_l = tmp_sig; MONO_ADD_INS (cfg->cbb, sig_arg); MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, RISCV_SP, cinfo->sig_cookie.offset, sig_arg->dreg); @@ -2728,8 +2728,15 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) } case OP_LOCALLOC_IMM: - if (ins->inst_imm > 32) - mono_decompose_op_imm (cfg, bb, ins); + if (ins->inst_imm > 32){ + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); + temp->inst_l = ins->inst_imm; + temp->dreg = mono_alloc_ireg (cfg); + + g_assert(mono_op_imm_to_op (ins->opcode) != -1); + ins->opcode = GINT_TO_OPCODE (mono_op_imm_to_op (ins->opcode)); + ins->sreg1 = temp->dreg; + } break; case OP_CALL_MEMBASE: @@ -2740,9 +2747,9 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_VOIDCALL_MEMBASE: if (!RISCV_VALID_J_IMM (ins->inst_offset)) { NOT_IMPLEMENTED; - NEW_INS_BEFORE (cfg, ins, temp, OP_ICONST); + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); temp->dreg = mono_alloc_ireg (cfg); - temp->inst_c0 = ins->inst_offset; + temp->inst_l = ins->inst_offset; ins->sreg1 = temp->dreg; @@ -2785,8 +2792,8 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) #endif case OP_STORE_MEMBASE_IMM: { if (ins->inst_imm != 0) { - NEW_INS_BEFORE (cfg, ins, temp, OP_ICONST); - temp->inst_c0 = ins->inst_imm; + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); + temp->inst_l = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); ins->sreg1 = temp->dreg; @@ -2842,9 +2849,9 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) * store rs1, 0(t0) */ int offset_reg = mono_alloc_ireg (cfg); - NEW_INS_BEFORE (cfg, ins, temp, OP_ICONST); + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); temp->dreg = offset_reg; - temp->inst_c0 = ins->inst_offset; + temp->inst_l = ins->inst_offset; #ifdef TARGET_RISCV64 NEW_INS_BEFORE (cfg, ins, temp, OP_LADD); @@ -2875,8 +2882,8 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_LOADR8_MEMBASE: case OP_LOAD_MEMBASE: if (!RISCV_VALID_I_IMM (ins->inst_imm)) { - NEW_INS_BEFORE (cfg, ins, temp, OP_ICONST); - temp->inst_c0 = ins->inst_imm; + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); + temp->inst_l = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); ins->sreg1 = temp->dreg; ins->inst_imm = 0; @@ -2952,8 +2959,8 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) if (ins->inst_imm == 0) { ins->sreg2 = RISCV_ZERO; } else { - NEW_INS_BEFORE (cfg, ins, temp, OP_ICONST); - temp->inst_c0 = ins->inst_imm; + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); + temp->inst_l = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); ins->sreg2 = temp->dreg; ins->inst_imm = 0; @@ -3182,7 +3189,13 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_IADD_IMM: case OP_LADD_IMM: if (!RISCV_VALID_I_IMM (ins->inst_imm)) { - mono_decompose_op_imm (cfg, bb, ins); + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); + temp->inst_l = ins->inst_imm; + temp->dreg = mono_alloc_ireg (cfg); + + g_assert(mono_op_imm_to_op (ins->opcode) != -1); + ins->opcode = GINT_TO_OPCODE (mono_op_imm_to_op (ins->opcode)); + ins->sreg2 = temp->dreg; } break; case OP_ADDCC: @@ -3235,8 +3248,8 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) } case OP_MUL_IMM: g_assert (riscv_stdext_m); - NEW_INS_BEFORE (cfg, ins, temp, OP_ICONST); - temp->inst_c0 = ins->inst_imm; + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); + temp->inst_l = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); ins->sreg2 = temp->dreg; ins->inst_imm = 0; @@ -3247,12 +3260,17 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) #endif break; case OP_DIV_IMM: - mono_decompose_op_imm (cfg, bb, ins); + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); + temp->inst_l = ins->inst_imm; + temp->dreg = mono_alloc_ireg (cfg); + #ifdef TARGET_RISCV64 - g_assert(ins->opcode == OP_LDIV); + g_assert(mono_op_imm_to_op (ins->opcode) == OP_LDIV); #else - g_assert(ins->opcode == OP_IDIV); + g_assert(mono_op_imm_to_op (ins->opcode) == OP_IDIV); #endif + ins->opcode = mono_op_imm_to_op (ins->opcode); + ins->sreg2 = temp->dreg; break; case OP_IMUL_IMM: case OP_LMUL_IMM: @@ -3261,7 +3279,13 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_LREM_IMM: case OP_IREM_UN_IMM: case OP_LREM_UN_IMM: - mono_decompose_op_imm (cfg, bb, ins); + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); + temp->inst_l = ins->inst_imm; + temp->dreg = mono_alloc_ireg (cfg); + + g_assert(mono_op_imm_to_op (ins->opcode) != -1); + ins->opcode = GINT_TO_OPCODE (mono_op_imm_to_op (ins->opcode)); + ins->sreg2 = temp->dreg; break; // Bit OP @@ -3282,8 +3306,15 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_ISHR_IMM: case OP_SHR_UN_IMM: case OP_ISHR_UN_IMM: - if (!RISCV_VALID_LS_AMOUNT (ins->inst_imm)) - mono_decompose_op_imm (cfg, bb, ins); + if (!RISCV_VALID_LS_AMOUNT (ins->inst_imm)){ + NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); + temp->inst_l = ins->inst_imm; + temp->dreg = mono_alloc_ireg (cfg); + + g_assert(mono_op_imm_to_op (ins->opcode) != -1); + ins->opcode = GINT_TO_OPCODE (mono_op_imm_to_op (ins->opcode)); + ins->sreg2 = temp->dreg; + } break; case OP_INOT: case OP_LNOT: @@ -3294,8 +3325,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_LCONV_TO_I1: // slli a0, a0, 56 // srai a0, a0, 56 - NEW_INS_BEFORE (cfg, ins, temp, OP_ICONST); - temp->opcode = OP_SHL_IMM; + NEW_INS_BEFORE (cfg, ins, temp, OP_SHL_IMM); temp->dreg = ins->dreg; temp->sreg1 = ins->sreg1; temp->inst_imm = 56; @@ -3315,8 +3345,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_LCONV_TO_U2: // slli a0, a0, 48 // srli a0, a0, 48 - NEW_INS_BEFORE (cfg, ins, temp, OP_ICONST); - temp->opcode = OP_SHL_IMM; + NEW_INS_BEFORE (cfg, ins, temp, OP_SHL_IMM); temp->dreg = ins->dreg; temp->sreg1 = ins->sreg1; temp->inst_imm = 48; @@ -3330,8 +3359,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_LCONV_TO_I2: // slli a0, a0, 48 // srai a0, a0, 48 - NEW_INS_BEFORE (cfg, ins, temp, OP_ICONST); - temp->opcode = OP_SHL_IMM; + NEW_INS_BEFORE (cfg, ins, temp, OP_SHL_IMM); temp->dreg = ins->dreg; temp->sreg1 = ins->sreg1; temp->inst_imm = 48; @@ -4484,8 +4512,10 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) code = mono_riscv_emit_store (code, ins->sreg1, ins->inst_destbasereg, ins->inst_offset, 8); break; case OP_ICONST: + code = mono_riscv_emit_imm (code, ins->dreg, (int)ins->inst_c0); + break; case OP_I8CONST: - code = mono_riscv_emit_imm (code, ins->dreg, ins->inst_c0); + code = mono_riscv_emit_imm (code, ins->dreg, ins->inst_l); break; case OP_IADD: #ifdef TARGET_RISCV64 From a7cd87172628bcde21ed8c730fc232cb40050ccf Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 26 Dec 2023 17:52:48 +0800 Subject: [PATCH 125/139] fix icompare --- src/mono/mono/mini/mini-riscv.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 89794d4ded093..ed7ecfde1228f 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3069,7 +3069,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) next_ins->sreg1 = ins->sreg1; next_ins->sreg2 = ins->sreg2; NULLIFY_INS (ins); - } else if (next_ins->opcode == OP_LCEQ || next_ins->opcode == OP_ICEQ) { + } else if (next_ins->opcode == OP_LCEQ) { // compare rs1, rs2; lceq rd => xor rd, rs1, rs2; sltiu rd, rd, 1 ins->opcode = OP_IXOR; ins->dreg = next_ins->dreg; @@ -3077,6 +3077,20 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) next_ins->opcode = OP_RISCV_SLTIU; next_ins->sreg1 = ins->dreg; next_ins->inst_imm = 1; + } else if (next_ins->opcode == OP_ICEQ){ + // compare rs1, rs2; lceq rd => xor rd, rs1, rs2; sltiu rd, rd, 1 + ins->opcode = OP_IXOR; + ins->dreg = next_ins->dreg; + + next_ins->opcode = OP_RISCV_SLTIU; + next_ins->sreg1 = ins->dreg; + next_ins->inst_imm = 1; + + // insert a sext.i4 between XOR and SLTIU + // will change next_ins pointer + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_SEXT_I4); + temp->dreg = ins->dreg; + temp->sreg1 = ins->dreg; } else if (next_ins->opcode == OP_ICNEQ) { // compare rs1, rs2; lcneq rd => xor rd, rs1, rs2; sltu rd, X0, rd ins->opcode = OP_IXOR; @@ -3085,6 +3099,12 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) next_ins->opcode = OP_RISCV_SLTU; next_ins->sreg1 = RISCV_ZERO; next_ins->sreg2 = ins->dreg; + + // insert a sext.i4 between XOR and SLTU + // will change next_ins pointer + NEW_INS_AFTER (cfg, ins, next_ins, temp, OP_SEXT_I4); + temp->dreg = ins->dreg; + temp->sreg1 = ins->dreg; } else if (next_ins->opcode == OP_LCGT || next_ins->opcode == OP_ICGT) { next_ins->opcode = OP_RISCV_SLT; next_ins->sreg1 = ins->sreg2; From 2d99a8ae6b76a5813995ca4ebd5c284707751da4 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Tue, 26 Dec 2023 18:56:38 +0800 Subject: [PATCH 126/139] fix OP_COND_EXC_IC for SUBCC --- src/mono/mono/mini/mini-riscv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index ed7ecfde1228f..1f2760939341d 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -3179,9 +3179,14 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) ins->opcode = OP_ISUB; MonoInst *branch_ins = next_ins; if (branch_ins) { - if (branch_ins->opcode == OP_COND_EXC_OV || next_ins->opcode == OP_COND_EXC_IOV || - branch_ins->opcode == OP_COND_EXC_NC || branch_ins->opcode == OP_COND_EXC_C || - branch_ins->opcode == OP_COND_EXC_IC) { + if (branch_ins->opcode == OP_COND_EXC_NC || branch_ins->opcode == OP_COND_EXC_C || + branch_ins->opcode == OP_COND_EXC_IC){ + // bltu rs1, rd, overflow + branch_ins->opcode = OP_RISCV_EXC_BLTU; + branch_ins->sreg1 = ins->sreg1; + branch_ins->sreg2 = ins->dreg; + } + else if (branch_ins->opcode == OP_COND_EXC_OV || next_ins->opcode == OP_COND_EXC_IOV) { // bne t1, t2, overflow branch_ins->opcode = OP_RISCV_EXC_BNE; branch_ins->sreg1 = mono_alloc_ireg (cfg); From 787db190fc43d09103636034f7c6644ae850bb50 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 27 Dec 2023 17:19:08 +0800 Subject: [PATCH 127/139] skip test of gc_poll --- src/tests/issues.targets | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 12c37bcde107b..598ca2aa4a52c 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -3664,4 +3664,10 @@ Condition="'%(ExcludeList.Extension)' == '.OutOfProcessTest'" /> + + + + function dlopen at mono-dl.c:250 can't open the native lib libGCPollNative.so + + From 173e8398b70f8e033ef7982eb2bcd6f7182967bd Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Wed, 27 Dec 2023 20:00:18 +0800 Subject: [PATCH 128/139] process OP_BR after OP_FCOMPARE --- src/mono/mono/mini/mini-riscv.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 1f2760939341d..a218f1ee5ab65 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -2717,7 +2717,10 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) next_ins->opcode = OP_RISCV_BNE; next_ins->sreg1 = ins->dreg; next_ins->sreg2 = RISCV_ZERO; - } else { + } else if (next_ins->opcode == OP_BR) { + NULLIFY_INS (ins); + } + else { g_print ("Unhandaled op %s following after OP_FCOMPARE\n", mono_inst_name (next_ins->opcode)); NOT_IMPLEMENTED; } From 51725ae825c0ec50b75c386025b66e2e8ef3b902 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 30 Dec 2023 14:22:39 +0800 Subject: [PATCH 129/139] skip gc_poll test --- src/tests/issues.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/issues.targets b/src/tests/issues.targets index 598ca2aa4a52c..d2a9dd249c12f 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -3665,7 +3665,7 @@ - + function dlopen at mono-dl.c:250 can't open the native lib libGCPollNative.so From 6f73cbc261b84fa6d451ac803b5d1932ce08f6b8 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 30 Dec 2023 14:23:19 +0800 Subject: [PATCH 130/139] tmp --- src/mono/mono/mini/mini-riscv.c | 2 +- src/tests/JIT/Methodical/Methodical_ro.csproj | 2 +- src/tests/run.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index a218f1ee5ab65..b0752307e0f00 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -5290,7 +5290,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) * we are called from EH code. */ if (cfg->param_area) - riscv_addi (code, RISCV_SP, RISCV_SP, -cfg->param_area); + riscv_addi (code, RISCV_SP, RISCV_SP, -ALIGN_TO (cfg->param_area, MONO_ARCH_FRAME_ALIGNMENT)); break; } case OP_CALL_HANDLER: diff --git a/src/tests/JIT/Methodical/Methodical_ro.csproj b/src/tests/JIT/Methodical/Methodical_ro.csproj index acf22626a849f..8e1cac5405b78 100644 --- a/src/tests/JIT/Methodical/Methodical_ro.csproj +++ b/src/tests/JIT/Methodical/Methodical_ro.csproj @@ -1,6 +1,6 @@ - + diff --git a/src/tests/run.py b/src/tests/run.py index a2d62d532b947..1dc453744cc5c 100755 --- a/src/tests/run.py +++ b/src/tests/run.py @@ -806,7 +806,7 @@ def run_tests(args, """ # Set default per-test timeout to 2 minutes (in milliseconds). - per_test_timeout = 4*60*1000 + per_test_timeout = 5*60*1000 # Setup the environment if args.long_gc: From 82793d7fe4fb6aae32cfafb4e4bce9f769653181 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 30 Dec 2023 15:10:21 +0800 Subject: [PATCH 131/139] clean the code --- .github/workflows/jit-riscv64.yml | 82 ----------- 2024.01.md | 39 ----- riscv64_build_test.sh | 4 - src/mono/mono/mini/helpers.c | 2 +- src/mono/sample/TestRun/.gdbinit | 29 ---- src/mono/sample/TestRun/Makefile | 136 ------------------ src/mono/sample/TestRun/TestRun.cs | 23 --- .../sample/TestRun/TestRun.runtimeconfig.json | 9 -- src/mono/sample/TestRun/trace_diff.py | 71 --------- src/tests/JIT/Methodical/Methodical_ro.csproj | 2 +- .../JitBlue/DevDiv_545500/DevDiv_545500.il | 3 +- src/tests/JIT/Regression/Regression_3.csproj | 2 +- src/tests/run.py | 11 +- src/tests/run.sh | 2 +- 14 files changed, 9 insertions(+), 406 deletions(-) delete mode 100644 .github/workflows/jit-riscv64.yml delete mode 100644 2024.01.md delete mode 100755 riscv64_build_test.sh delete mode 100644 src/mono/sample/TestRun/.gdbinit delete mode 100644 src/mono/sample/TestRun/Makefile delete mode 100644 src/mono/sample/TestRun/TestRun.cs delete mode 100644 src/mono/sample/TestRun/TestRun.runtimeconfig.json delete mode 100644 src/mono/sample/TestRun/trace_diff.py diff --git a/.github/workflows/jit-riscv64.yml b/.github/workflows/jit-riscv64.yml deleted file mode 100644 index 22318010a68ad..0000000000000 --- a/.github/workflows/jit-riscv64.yml +++ /dev/null @@ -1,82 +0,0 @@ -on: - workflow_dispatch: - push: - branches: - - riscv-jit-rv64 - -jobs: - cross-build: - runs-on: ubuntu-latest - container: - image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-riscv64 - env: - ROOTFS_DIR: /crossrootfs/riscv64 - QEMU_LD_PREFIX: /crossrootfs/riscv64 - steps: - - name: Checkout - uses: actions/checkout@v2 - # cache - - name: Cache - uses: actions/cache@v2 - with: - path: | - .dotnet/ - artifacts/ - key: ${{ runner.os }}-dotnet-cross-build - - - name: Cross Build Libs & host - run: ./build.sh libs -c Release --cross --arch riscv64 --ci - - - name: Cross Build Mono - # ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build - run: ./build.sh mono+libs+host+clr.hosts -c Debug --cross --arch riscv64 --ci - - - name: compress files - run: tar -zcf runtime.tar.gz ./.dotnet ./artifacts - # upload entire project - - name: Upload Artifacts - uses: actions/upload-artifact@v2 - with: - name: runtime.tar.gz - path: ./runtime.tar.gz - - test: - continue-on-error: true - runs-on: ubuntu-latest - container: - image: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-22.04-cross-riscv64 - env: - ROOTFS_DIR: /crossrootfs/riscv64 - QEMU_LD_PREFIX: /crossrootfs/riscv64 - CORE_ROOT: /__w/runtime/runtime/artifacts/tests/coreclr/linux.riscv64.Debug/Tests/Core_Root - # set timeout to 5 minutes - __TestTimeout: 300000 - needs: cross-build - steps: - - name: Checkout - uses: actions/checkout@v2 - - name: Download Artifacts - uses: actions/download-artifact@v2 - with: - name: runtime.tar.gz - - name: Decompress - run: tar -zxf runtime.tar.gz -C ./ - - name: Cache - uses: actions/cache@v2 - with: - path: | - artifacts/tests/ - key: ${{ runner.os }}-dotnet-cross-build - - name: Build Tests programs - run: ./build.sh -mono -Debug riscv64 -tree:JIT/ --ci - working-directory: ./src/tests - - name: Run tests - run: qemu-riscv64-static /crossrootfs/riscv64/bin/bash -c ./run.sh Debug - working-directory: ./src/tests - - name: Upload Test error Log - if: ${{ failure() }} - uses: actions/upload-artifact@v2 - with: - name: test-error-log.log - path: ./artifacts/log/TestRunResults_linux_riscv64_Debug.log - diff --git a/2024.01.md b/2024.01.md deleted file mode 100644 index 7af8b9748c59f..0000000000000 --- a/2024.01.md +++ /dev/null @@ -1,39 +0,0 @@ -# 2024年预期产出 - -> 本周期内预计持续完善Mono的RISC-V 支持。尝试打包 RISC-V 的 runtime安装包 ,并且尝试帮助/推进runtime 建立对于在 RISC-V 上Native构建Mono的的二进制文件支持。 - -## 实现Mono的RISC-V支持 - - 目标:实现 Mono RISC-V 的稳定运行并通过相关的回归测试。具体时长可能会随着验证进度被缩短/增加 - - - 交付: - 1. 向上游(dotnet/runtime)提交Mono后端RISC-V支持的PR - 2. 测试运行结果,失败项目的失败原因。 - - - 验收指标: PR被接收,CI通过 - - 周期:2-3 个月 - -## 尝试打包 RISC-V 的runtime安装包 - > 预期可能需要使用微软/dotnet提供一些闭源的二进制工具集? 因此可能需要上游的指导。 - - 目标:尝试编译并且打包以Mono RISC-V为后端的dotnet安装包。 - - - 交付: - 1. 一个类似`dotnet-sdk--linux-riscv64.tar.gz`的压缩包,其中应包括dotnet程序以及相关运行库,.Net Runtime library,.Net SDKs 以及安装脚本等。 - 2. 与上游沟通并将安装包发布在`https://dotnetcli.azureedge.net/dotnet/Sdk/` - - - 验收指标: dotnet可以直接被`dotnet-install.sh`解压并安装在RISC-V设备或qemu-system中 - - 周期:1-2个月 - -## 实现RISC-V上Native构建dotnet/runtime - - 先决条件: 拥有一个可以在RISC-V设备/qemu-system中独立安装的安装包。Mono RISC-V可以正确运行roslyn。 - - - 目标:在RISC-V设备或qemu-system中构建并打包dotnet安装包。 - - - 交付:向上游(dotnet/runtime)提交PR修复运行roslyn时Mono RISC-V出现的Bug - - 验收指标:可以在`qemu-system-riscv64`编译打包dotnet安装包。 - - 周期:1-2个月 - -## 在RISC-V运行图形程序 - - 目标:尝试在RISC-V开发板/qemu-system上使用Mono运行图形程序,例如星露谷物语。 - - 交付:向上游(dotnet/runtime)提交PR修复运行图形程序时Mono RISC-V出现的Bug - - 验收指标:可以在`qemu-system-riscv64`运行图形程序如游戏星露谷物语 - - 周期:2-3个月 diff --git a/riscv64_build_test.sh b/riscv64_build_test.sh deleted file mode 100755 index 2c39779391727..0000000000000 --- a/riscv64_build_test.sh +++ /dev/null @@ -1,4 +0,0 @@ -cd src/tests -./build.sh -mono -debug riscv64 -ninja /p:KeepNativeSymbols=true -tree:JIT/ - -cd ../.. \ No newline at end of file diff --git a/src/mono/mono/mini/helpers.c b/src/mono/mono/mini/helpers.c index 83a72abfa2173..9d903fdbc24a5 100644 --- a/src/mono/mono/mini/helpers.c +++ b/src/mono/mono/mini/helpers.c @@ -274,7 +274,7 @@ MONO_RESTORE_WARNING g_free (cmd); #endif - cmd = g_strdup_printf ("llvm-objdump -d --arch=rv64gc %s %s", objdump_args, o_file); + cmd = g_strdup_printf (ARCH_PREFIX DIS_CMD " %s %s", objdump_args, o_file); unused = system (cmd); g_free (cmd); g_free (objdump_args); diff --git a/src/mono/sample/TestRun/.gdbinit b/src/mono/sample/TestRun/.gdbinit deleted file mode 100644 index ae092457a95f4..0000000000000 --- a/src/mono/sample/TestRun/.gdbinit +++ /dev/null @@ -1,29 +0,0 @@ -handle SIGXCPU SIG33 SIG35 SIG36 SIG37 SIG38 SIGPWR nostop print - -define mono_backtrace - select-frame 0 - set $i = 0 - while ($i < $arg0) - set $foo = (char*) mono_pmip ($pc) - if ($foo) - printf "#%d %p in %s\n", $i, $pc, $foo - else - frame - end - up-silently - set $i = $i + 1 - end -end - -define mono_stack - set $mono_thread = mono_thread_current () - if ($mono_thread == 0x00) - printf "No mono thread associated with this thread\n" - else - set $ucp = malloc (sizeof (ucontext_t)) - call (void) getcontext ($ucp) - call (void) mono_print_thread_dump ($ucp) - call (void) free ($ucp) - end -end - diff --git a/src/mono/sample/TestRun/Makefile b/src/mono/sample/TestRun/Makefile deleted file mode 100644 index 99055040cd625..0000000000000 --- a/src/mono/sample/TestRun/Makefile +++ /dev/null @@ -1,136 +0,0 @@ -TOP=../../../../ -DOTNET:=$(TOP)dotnet.sh -DOTNET_Q_ARGS=--nologo -v:q -consoleloggerparameters:NoSummary - -MONO_CONFIG?=Debug -MONO_ARCH=riscv64 -TARGET_OS=linux -AOT?=false -QEMU=qemu-riscv64-static -SAMPLE_PATH=/home/wuxinlong/workspace/samples/csharp/getting-started/console-webapiclient -CORE_BASELINE_ROOT=/home/wuxinlong/workspace/runtime/artifacts/tests/coreclr/linux.x64.Debug/Tests/Core_Root -ANY_PATH= /home/wuxinlong/workspace/runtime/artifacts/tests/coreclr/linux.x64.Debug/JIT/Directed/Directed_3/Directed_3.dll - -GitHubKey=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 - -#NET_TRACE_PATH= -#PGO_BINARY_PATH= -#MIBC_PROFILE_PATH= - -MONO_ENV_DEBUG_OPTIONS = "-v --trace=all --break StrAccess1:Run" -MONO_ENV_RUN_OPTIONS="" - -build: TestRun.cs - @mcs TestRun.cs - -run-baseline: build - COMPlus_DebugWriteToStdErr=1 \ - MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ - $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-x64/dotnet TestRun.exe - -run-any-baseline: - COMPlus_DebugWriteToStdErr=1 \ - MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ - CORE_ROOT=${CORE_BASELINE_ROOT} \ - ${CORE_BASELINE_ROOT}/corerun -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true $(ANY_PATH) - -run: build - @COMPlus_DebugWriteToStdErr=1 \ - MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ $(TOP)artifacts/bin/testhost/net9.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet TestRun.exe - -run-any: - COMPlus_DebugWriteToStdErr=1 \ - MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ - ${CORE_ROOT}/corerun -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true $(ANY_PATH) - -run-webapiclient-baseline: - COMPlus_DebugWriteToStdErr=1 \ - MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ - $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-x64/dotnet \ - $(SAMPLE_PATH)/bin/Debug/net8.0/webapiclient.dll - -run-webapiclient: - COMPlus_DebugWriteToStdErr=1 \ - MONO_ENV_OPTIONS=$(MONO_ENV_RUN_OPTIONS) \ - $(QEMU) -L $(TOP).tools/rootfs/riscv64/ \ - $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/dotnet \ - $(SAMPLE_PATH)/bin/Debug/net8.0/webapiclient.dll - -debug: build - COMPlus_DebugWriteToStdErr=1 \ - MONO_LOG_LEVEL=debug MONO_LOG_MASK=all \ - MONO_ENV_OPTIONS=$(MONO_ENV_DEBUG_OPTIONS) \ - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ \ - -g 12345 \ - $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet TestRun.exe &\ - gdb-multiarch -ex 'target remote localhost:12345' \ - -ex "set sysroot $(TOP).tools/rootfs/riscv64" -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/shared/Microsoft.NETCore.App/8.0.0" \ - -ex "b mini.c:2156" \ - $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet - -debug-webapiclient: - COMPlus_DebugWriteToStdErr=1 \ - MONO_ENV_OPTIONS=$(MONO_ENV_DEBUG_OPTIONS) \ - $(QEMU) -L $(TOP)/.tools/rootfs/riscv64/ \ - -g 12345 \ - $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet \ - $(SAMPLE_PATH)/bin/Debug/net8.0/webapiclient.dll &\ - gdb-multiarch -ex 'target remote localhost:12345' \ - -ex "set sysroot $(TOP).tools/rootfs/riscv64" \ - -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/shared/Microsoft.NETCore.App/8.0.0" \ - -ex "b mini.c:2156" \ - $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-$(MONO_ARCH)/dotnet - -debug-any: - COMPlus_DebugWriteToStdErr=1 \ - MONO_ENV_OPTIONS=$(MONO_ENV_DEBUG_OPTIONS) \ - $(QEMU) -g 12345 \ - ${CORE_ROOT}/corerun -p System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization=true $(ANY_PATH) &\ - gdb-multiarch -ex 'target remote localhost:12345' \ - -iex "add-auto-load-safe-path /home/wuxinlong/workspace/runtime/src/mono/sample/TestRun/" \ - -ex "set sysroot $(TOP).tools/rootfs/riscv64" \ - -ex "set solib-search-path ${CORE_ROOT}" \ - -ex "b mono_break" \ - -ex "handle SIGXCPU SIG33 SIG35 SIG36 SIG37 SIG38 SIGPWR print nostop ignore" \ - ${CORE_ROOT}/corerun - -remote_gdb: - gdb-multiarch -ex 'target remote localhost:32427' \ - -iex "add-auto-load-safe-path /home/wuxinlong/workspace/runtime/src/mono/sample/TestRun/" \ - -ex "set sysroot $(TOP).tools/rootfs/riscv64" \ - -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-riscv64/shared/Microsoft.NETCore.App/8.0.0" \ - -ex "b mini.c:2156" \ - -ex "handle SIG35 print nostop ignore" \ - ${CORE_ROOT}/corerun - - -debug-any-baseline: - COMPlus_DebugWriteToStdErr=1 \ - MONO_ENV_OPTIONS=$(MONO_ENV_DEBUG_OPTIONS) \ - gdb \ - -ex "set solib-search-path $(TOP)artifacts/bin/testhost/net8.0-linux-Debug-x86/shared/Microsoft.NETCore.App/8.0.0" \ - -ex "b mini.c:2156" \ - --args $(TOP)artifacts/bin/testhost/net8.0-$(TARGET_OS)-Debug-x64/dotnet \ - $(ANY_PATH) \ - -clean: - rm -f *.exe *.exe.mdb - -# ILGEN_0xf64b7da3:Method_0xcb0b0b48 -# 306 - -# converting method PrimitiveVT.VT1B PrimitiveVT.CallConv3:f2 (PrimitiveVT.VT1A,PrimitiveVT.VT1B) - -# COMPlus_DebugWriteToStdErr="1" MONO_LOG_LEVEL="debug" MONO_LOG_MASK="all" COREHOST_TRACE="1" COREHOST_TRACE_VERBOSITY="4" MONO_ENV_OPTIONS="--compile-all --trace=all" qemu-riscv64 -L ../../../..//.tools/rootfs/riscv64/ -g 12345 ../../../../artifacts/bin/testhost/net8.0-Linux-Debug-riscv64/dotnet TestRun.exe - -# ROOTFS_DIR="" ./build.sh mono+libs+host -c Debug -# ./build.sh mono+libs+host -c Debug --cross --arch riscv64 --build - -# ROOTFS_DIR="" ./build.sh clr.hosts -c Debug - -# ROOTFS_DIR="" ./build.sh mono+libs+host -c Debug --ninja /p:KeepNativeSymbols=true -# ./build.sh mono+libs+host+clr.host -c Debug --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true --build -# CORT_ROOT=/home/wuxinlong/workspace/runtime/artifacts/tests/coreclr/linux.x64.Debug -# ./build.sh -mono -debug riscv64 -ninja /p:KeepNativeSymbols=true -# ./build.sh clr.hosts --cross --arch riscv64 --ninja /p:KeepNativeSymbols=true diff --git a/src/mono/sample/TestRun/TestRun.cs b/src/mono/sample/TestRun/TestRun.cs deleted file mode 100644 index 6f963afbf91d5..0000000000000 --- a/src/mono/sample/TestRun/TestRun.cs +++ /dev/null @@ -1,23 +0,0 @@ -// C# Hello World - -using System; - -public class Test -{ - public static void TestRun() - { - int i; - int len = 50; - var rand = new Random(); - while (len != 0) - { - i = rand.Next(0, 1); - len /= 2; - } - } - - public static void Main() - { - TestRun(); - } -} \ No newline at end of file diff --git a/src/mono/sample/TestRun/TestRun.runtimeconfig.json b/src/mono/sample/TestRun/TestRun.runtimeconfig.json deleted file mode 100644 index ef8c92c382190..0000000000000 --- a/src/mono/sample/TestRun/TestRun.runtimeconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "runtimeOptions": { - "tfm": "net9.0", - "framework": { - "name": "Microsoft.NETCore.App", - "version": "9.0.0" - } - } - } \ No newline at end of file diff --git a/src/mono/sample/TestRun/trace_diff.py b/src/mono/sample/TestRun/trace_diff.py deleted file mode 100644 index c237455e6bccb..0000000000000 --- a/src/mono/sample/TestRun/trace_diff.py +++ /dev/null @@ -1,71 +0,0 @@ -import sys -import re - -def compare_stacks(file1_path, file2_path): - try: - with open(file1_path, "r") as file1, open(file2_path, "r") as file2: - baseline_lines = file1.readlines() - comparison_lines = file2.readlines() - - index1, index2 = 0, 0 - last_command = None - - while index1 < len(baseline_lines) and index2 < len(comparison_lines): - stack1 = baseline_lines[index1].strip() - stack2 = comparison_lines[index2].strip() - - # 使用正则表达式匹配重要信息 - pattern = re.compile(r'(\[([^:]+): ([\d.]+) (\d+)\]) (ENTER|LEAVE):c (.+?) (\(.*?\)|\()(\(.+?\)|\()') - match1 = pattern.match(stack1) - match2 = pattern.match(stack2) - - if match1 and match2: - sameStackDeeps = match1.group(4) == match2.group(4) - sameFuncAction = match1.group(5) == match2.group(5) - sameFuncSig = match1.group(6) == match2.group(6) and match1.group(7) == match2.group(7) - file1Param = match1.group(8) - file2Param = match1.group(8) - if sameStackDeeps and sameFuncAction and sameFuncSig: - # print(f"Stacks are identical at line {index1 + 1}") - index1 += 1 - index2 += 1 - else: - print(f"Difference found at") - print(f"File 1, Line {index1 + 1}: {stack1}") - print(f"File 2, Line {index2 + 1}: {stack2}") - command = input("Enter '1' to move File 1 to the next line, '2' to move File 2 to the next line, 'q' to quit: ") - - if command == '': - command = last_command - - if command == '1': - index1 += 1 - elif command == '2': - index2 += 1 - elif command == 'q': - break - else: - print("Invalid command. Please enter '1', '2', or 'q'.") - - last_command = command - else: - # 如果无法匹配到重要信息,直接跳到下一行 - print(stack1) - print(stack2) - index1 += 1 - index2 += 1 - - print("Comparison complete.") - - except FileNotFoundError as e: - print(f"Error: {e.filename} not found.") - except Exception as e: - print(f"An error occurred: {e}") - -if __name__ == "__main__": - if len(sys.argv) != 3: - print("Usage: python trace_diff.py ") - else: - baseline_file_path = sys.argv[1] - comparison_file_path = sys.argv[2] - compare_stacks(baseline_file_path, comparison_file_path) diff --git a/src/tests/JIT/Methodical/Methodical_ro.csproj b/src/tests/JIT/Methodical/Methodical_ro.csproj index 8e1cac5405b78..acf22626a849f 100644 --- a/src/tests/JIT/Methodical/Methodical_ro.csproj +++ b/src/tests/JIT/Methodical/Methodical_ro.csproj @@ -1,6 +1,6 @@ - + diff --git a/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il b/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il index b5effff3389c6..8982bce3b1425 100644 --- a/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il +++ b/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il @@ -125,8 +125,7 @@ L1: ldarg.s 0x1 conv.u8 cgt shr.un - neg - conv.u1 + neg ret } // end of method DevDiv_545500:Test diff --git a/src/tests/JIT/Regression/Regression_3.csproj b/src/tests/JIT/Regression/Regression_3.csproj index 93891ff7b3074..4eafe2b2450fb 100644 --- a/src/tests/JIT/Regression/Regression_3.csproj +++ b/src/tests/JIT/Regression/Regression_3.csproj @@ -5,4 +5,4 @@ - \ No newline at end of file + diff --git a/src/tests/run.py b/src/tests/run.py index 1dc453744cc5c..5f2a90c4468ab 100755 --- a/src/tests/run.py +++ b/src/tests/run.py @@ -805,8 +805,8 @@ def run_tests(args, test_env_script_path : Path to script to use to set the test environment, if any. """ - # Set default per-test timeout to 2 minutes (in milliseconds). - per_test_timeout = 5*60*1000 + # Set default per-test timeout to 30 minutes (in milliseconds). + per_test_timeout = 30*60*1000 # Setup the environment if args.long_gc: @@ -862,11 +862,8 @@ def run_tests(args, # Set __TestTimeout environment variable, which is the per-test timeout in milliseconds. # This is read by the test wrapper invoker, in src\tests\Common\Coreclr.TestWrapper\CoreclrTestWrapperLib.cs. - if "__TestTimeout" in os.environ: - print("__TestTimeout already set in environment to %s" % os.environ["__TestTimeout"]) - else: - print("Setting __TestTimeout=%s" % str(per_test_timeout)) - os.environ["__TestTimeout"] = str(per_test_timeout) + print("Setting __TestTimeout=%s" % str(per_test_timeout)) + os.environ["__TestTimeout"] = str(per_test_timeout) # Set CORE_ROOT print("Setting CORE_ROOT=%s" % args.core_root) diff --git a/src/tests/run.sh b/src/tests/run.sh index 60a75169b7069..fe809ac3b6f7f 100755 --- a/src/tests/run.sh +++ b/src/tests/run.sh @@ -53,7 +53,7 @@ repoRootDir="$(cd "$scriptPath"/../..; pwd -P)" source "$repoRootDir/eng/native/init-os-and-arch.sh" # Argument variables -buildArch="riscv64" +buildArch="$arch" buildOS= buildConfiguration="Debug" testRootDir= From 40875b886805509efc9b13b34b1fc949ebb5e7f2 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 30 Dec 2023 15:19:55 +0800 Subject: [PATCH 132/139] clean --- src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il b/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il index 8982bce3b1425..fc330a956664e 100644 --- a/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il +++ b/src/tests/JIT/Regression/JitBlue/DevDiv_545500/DevDiv_545500.il @@ -125,7 +125,7 @@ L1: ldarg.s 0x1 conv.u8 cgt shr.un - neg + neg ret } // end of method DevDiv_545500:Test From 966ea752d5bbb8ed85753f8eabbb7232ad9eee3e Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 30 Dec 2023 15:25:02 +0800 Subject: [PATCH 133/139] clang format file --- src/mono/.clang-format | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 src/mono/.clang-format diff --git a/src/mono/.clang-format b/src/mono/.clang-format new file mode 100644 index 0000000000000..c0a6e9b7f6798 --- /dev/null +++ b/src/mono/.clang-format @@ -0,0 +1,81 @@ +--- +Language: Cpp +AccessModifierOffset: -4 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignConsecutiveMacros: true +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType : AllDefinitions +AlwaysBreakBeforeMultilineStrings: false +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: false +BraceWrapping: + AfterClass: true + AfterControlStatement: true + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: true + AfterUnion: true + BeforeCatch: true + BeforeElse: true + IndentBraces: false +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Linux +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ ] +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 400 +PenaltyBreakComment: 50 +PenaltyBreakFirstLessLess: 500 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 100000 +PointerAlignment: Right +ReflowComments: true +SortIncludes: false +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: Always +SpaceBeforeSquareBrackets: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 4 +UseTab: ForIndentation From d9affd893a469eb6c8b1b179c66ec7f3fa035c40 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 30 Dec 2023 15:25:09 +0800 Subject: [PATCH 134/139] fmt --- src/mono/mono/arch/riscv/riscv-codegen.h | 16 +- src/mono/mono/mini/mini-ops.h | 4 +- src/mono/mono/mini/mini-riscv.c | 187 +++++++++++------------ src/mono/mono/mini/mini-riscv.h | 8 +- 4 files changed, 106 insertions(+), 109 deletions(-) diff --git a/src/mono/mono/arch/riscv/riscv-codegen.h b/src/mono/mono/arch/riscv/riscv-codegen.h index 389ef465e50a7..1cd369c2bd9d1 100644 --- a/src/mono/mono/arch/riscv/riscv-codegen.h +++ b/src/mono/mono/arch/riscv/riscv-codegen.h @@ -254,17 +254,17 @@ enum { enum { RISCV_FCLASS_NINF = 0b1 << 0, // Negative infinity. - RISCV_FCLASS_NN = 0b1 << 1, // Negative normal. - RISCV_FCLASS_ND = 0b1 << 2, // Negative denormal. - RISCV_FCLASS_NZ = 0b1 << 3, // Negative zero. - RISCV_FCLASS_PZ = 0b1 << 4, // Positive zero. - RISCV_FCLASS_PD = 0b1 << 5, // Positive denormal. - RISCV_FCLASS_PN = 0b1 << 6, // Positive normal. + RISCV_FCLASS_NN = 0b1 << 1, // Negative normal. + RISCV_FCLASS_ND = 0b1 << 2, // Negative denormal. + RISCV_FCLASS_NZ = 0b1 << 3, // Negative zero. + RISCV_FCLASS_PZ = 0b1 << 4, // Positive zero. + RISCV_FCLASS_PD = 0b1 << 5, // Positive denormal. + RISCV_FCLASS_PN = 0b1 << 6, // Positive normal. RISCV_FCLASS_PINF = 0b1 << 7, // Positive infinity. RISCV_FCLASS_SNAN = 0b1 << 8, // Signalling NaN. RISCV_FCLASS_QNAN = 0b1 << 9, // Quiet NaN. - RISCV_FCLASS_INF = RISCV_FCLASS_NINF | RISCV_FCLASS_PINF, - RISCV_FCLASS_NAN = RISCV_FCLASS_SNAN | RISCV_FCLASS_QNAN, + RISCV_FCLASS_INF = RISCV_FCLASS_NINF | RISCV_FCLASS_PINF, + RISCV_FCLASS_NAN = RISCV_FCLASS_SNAN | RISCV_FCLASS_QNAN, }; #define _riscv_emit(p, insn) \ diff --git a/src/mono/mono/mini/mini-ops.h b/src/mono/mono/mini/mini-ops.h index ccdc1726a3025..4108489d1beb1 100644 --- a/src/mono/mono/mini/mini-ops.h +++ b/src/mono/mono/mini/mini-ops.h @@ -1889,8 +1889,8 @@ MINI_OP(OP_RISCV_BGE, "riscv_bge", NONE, IREG, IREG) MINI_OP(OP_RISCV_BGEU, "riscv_bgeu", NONE, IREG, IREG) MINI_OP(OP_RISCV_BLT, "riscv_blt", NONE, IREG, IREG) MINI_OP(OP_RISCV_BLTU, "riscv_bltu", NONE, IREG, IREG) -MINI_OP(OP_RISCV_RBNAN, "riscv_r4_bnan", NONE, FREG, NONE) -MINI_OP(OP_RISCV_FBNAN, "riscv_float_bnan", NONE, FREG, NONE) +MINI_OP (OP_RISCV_RBNAN, "riscv_r4_bnan", NONE, FREG, NONE) +MINI_OP (OP_RISCV_FBNAN, "riscv_float_bnan", NONE, FREG, NONE) MINI_OP(OP_RISCV_ADDIW, "riscv_addiw", IREG, IREG, NONE) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index b0752307e0f00..b88778efacce2 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1297,7 +1297,7 @@ mono_arch_tailcall_supported (MonoCompile *cfg, MonoMethodSignature *caller_sig, CallInfo *callee_info = get_call_info (NULL, callee_sig); // Do not tail call optimize functions with varargs passed by stack. - gboolean res = IS_SUPPORTED_TAILCALL(callee_sig->call_convention != MONO_CALL_VARARG); + gboolean res = IS_SUPPORTED_TAILCALL (callee_sig->call_convention != MONO_CALL_VARARG); // Byval parameters hand the function a pointer directly into the stack area // we want to reuse during a tail call. Do not tail call optimize functions with @@ -1886,7 +1886,7 @@ mono_arch_decompose_opts (MonoCompile *cfg, MonoInst *ins) case OP_LCONV_TO_U4: case OP_LCONV_TO_I8: case OP_LCONV_TO_U8: - + case OP_LCONV_TO_OVF_I: case OP_LCONV_TO_OVF_I_UN: case OP_LCONV_TO_OVF_U: @@ -2250,7 +2250,7 @@ mono_arch_allocate_vars (MonoCompile *cfg) MONO_INST_NEW ((cfg), (dest), (op)); \ (dest)->cil_code = (ins)->cil_code; \ mono_bblock_insert_after_ins (bb, ins, (dest)); \ - next_ins = dest; \ + next_ins = dest; \ } while (0) /* @@ -2434,7 +2434,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) break; } case OP_RCGE: - case OP_FCGE:{ + case OP_FCGE: { // rcge rd, rs1, rs2 -> rcle rd, rs2, rs1 if (ins->opcode == OP_FCGE) ins->opcode = OP_FCLE; @@ -2446,7 +2446,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) break; } case OP_RCNEQ: - case OP_FCNEQ:{ + case OP_FCNEQ: { // fcneq rd, rs1, rs2 -> fceq rd, rs1, rs2, ceq rd, rd, zero if (ins->opcode == OP_FCNEQ) ins->opcode = OP_FCEQ; @@ -2468,7 +2468,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) break; } case OP_FCONV_TO_I1: - case OP_RCONV_TO_I1:{ + case OP_RCONV_TO_I1: { // fconv_to_i1 rd, fs1 => fconv_to_i{4|8} rs1, fs1; {i|l}conv_to_i1 rd, rs1 int rd = ins->dreg; #ifdef TARGET_RISCV64 @@ -2570,15 +2570,15 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) if (next_ins) { // insert two OP_RISCV_FBNAN in case unordered compare if (next_ins->opcode == OP_FBLT_UN || next_ins->opcode == OP_FBGT_UN || - next_ins->opcode == OP_FBGE_UN || next_ins->opcode == OP_FBLE_UN || - next_ins->opcode == OP_FBNE_UN){ - NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_RBNAN); + next_ins->opcode == OP_FBGE_UN || next_ins->opcode == OP_FBLE_UN || + next_ins->opcode == OP_FBNE_UN) { + NEW_INS_BEFORE (cfg, ins, temp, OP_RISCV_RBNAN); temp->sreg1 = ins->sreg1; - temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof (gpointer) * 2); temp->inst_true_bb = next_ins->inst_true_bb; - NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_RBNAN); + NEW_INS_BEFORE (cfg, ins, temp, OP_RISCV_RBNAN); temp->sreg1 = ins->sreg2; - temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof (gpointer) * 2); temp->inst_true_bb = next_ins->inst_true_bb; } @@ -2631,12 +2631,11 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) // rcmp rs1, rs2; fbne rd -> rceq rd, rs1, rs2; beq rd, X0 ins->opcode = OP_RCEQ; ins->dreg = mono_alloc_ireg (cfg); - + next_ins->opcode = OP_RISCV_BEQ; next_ins->sreg1 = ins->dreg; next_ins->sreg2 = RISCV_ZERO; - } - else { + } else { g_print ("Unhandaled op %s following after OP_RCOMPARE\n", mono_inst_name (next_ins->opcode)); NOT_IMPLEMENTED; } @@ -2648,16 +2647,16 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_FCOMPARE: { if (next_ins) { if (next_ins->opcode == OP_FBLT_UN || next_ins->opcode == OP_FBGT_UN || - next_ins->opcode == OP_FBGE_UN || next_ins->opcode == OP_FBLE_UN || - next_ins->opcode == OP_FBNE_UN){ + next_ins->opcode == OP_FBGE_UN || next_ins->opcode == OP_FBLE_UN || + next_ins->opcode == OP_FBNE_UN) { // insert two OP_RISCV_FBNAN in case unordered compare - NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_FBNAN); + NEW_INS_BEFORE (cfg, ins, temp, OP_RISCV_FBNAN); temp->sreg1 = ins->sreg1; - temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof (gpointer) * 2); temp->inst_true_bb = next_ins->inst_true_bb; - NEW_INS_BEFORE(cfg, ins, temp, OP_RISCV_FBNAN); + NEW_INS_BEFORE (cfg, ins, temp, OP_RISCV_FBNAN); temp->sreg1 = ins->sreg2; - temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof(gpointer)*2); + temp->inst_many_bb = mono_mempool_alloc (cfg->mempool, sizeof (gpointer) * 2); temp->inst_true_bb = next_ins->inst_true_bb; } @@ -2690,7 +2689,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) next_ins->opcode = OP_RISCV_BNE; next_ins->sreg1 = ins->dreg; next_ins->sreg2 = RISCV_ZERO; - } else if (next_ins->opcode == OP_FBLE || next_ins->opcode == OP_FBLE_UN){ + } else if (next_ins->opcode == OP_FBLE || next_ins->opcode == OP_FBLE_UN) { ins->opcode = OP_FCLE; ins->dreg = mono_alloc_ireg (cfg); @@ -2719,8 +2718,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) next_ins->sreg2 = RISCV_ZERO; } else if (next_ins->opcode == OP_BR) { NULLIFY_INS (ins); - } - else { + } else { g_print ("Unhandaled op %s following after OP_FCOMPARE\n", mono_inst_name (next_ins->opcode)); NOT_IMPLEMENTED; } @@ -2731,12 +2729,12 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) } case OP_LOCALLOC_IMM: - if (ins->inst_imm > 32){ + if (ins->inst_imm > 32) { NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); temp->inst_l = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); - g_assert(mono_op_imm_to_op (ins->opcode) != -1); + g_assert (mono_op_imm_to_op (ins->opcode) != -1); ins->opcode = GINT_TO_OPCODE (mono_op_imm_to_op (ins->opcode)); ins->sreg1 = temp->dreg; } @@ -3080,7 +3078,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) next_ins->opcode = OP_RISCV_SLTIU; next_ins->sreg1 = ins->dreg; next_ins->inst_imm = 1; - } else if (next_ins->opcode == OP_ICEQ){ + } else if (next_ins->opcode == OP_ICEQ) { // compare rs1, rs2; lceq rd => xor rd, rs1, rs2; sltiu rd, rd, 1 ins->opcode = OP_IXOR; ins->dreg = next_ins->dreg; @@ -3169,27 +3167,25 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) * slt t2, rd, rs1 * bne t1, t2, overflow */ - if (ins->opcode == OP_SUBCC){ + if (ins->opcode == OP_SUBCC) { #ifdef TARGET_RISCV64 ins->opcode = OP_LSUB; #else ins->opcode = OP_ISUB; #endif - } - else if (ins->opcode == OP_LSUBCC) + } else if (ins->opcode == OP_LSUBCC) ins->opcode = OP_LSUB; else ins->opcode = OP_ISUB; MonoInst *branch_ins = next_ins; if (branch_ins) { if (branch_ins->opcode == OP_COND_EXC_NC || branch_ins->opcode == OP_COND_EXC_C || - branch_ins->opcode == OP_COND_EXC_IC){ - // bltu rs1, rd, overflow - branch_ins->opcode = OP_RISCV_EXC_BLTU; - branch_ins->sreg1 = ins->sreg1; - branch_ins->sreg2 = ins->dreg; - } - else if (branch_ins->opcode == OP_COND_EXC_OV || next_ins->opcode == OP_COND_EXC_IOV) { + branch_ins->opcode == OP_COND_EXC_IC) { + // bltu rs1, rd, overflow + branch_ins->opcode = OP_RISCV_EXC_BLTU; + branch_ins->sreg1 = ins->sreg1; + branch_ins->sreg2 = ins->dreg; + } else if (branch_ins->opcode == OP_COND_EXC_OV || next_ins->opcode == OP_COND_EXC_IOV) { // bne t1, t2, overflow branch_ins->opcode = OP_RISCV_EXC_BNE; branch_ins->sreg1 = mono_alloc_ireg (cfg); @@ -3221,7 +3217,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) temp->inst_l = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); - g_assert(mono_op_imm_to_op (ins->opcode) != -1); + g_assert (mono_op_imm_to_op (ins->opcode) != -1); ins->opcode = GINT_TO_OPCODE (mono_op_imm_to_op (ins->opcode)); ins->sreg2 = temp->dreg; } @@ -3243,14 +3239,13 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) MonoInst *branch_ins = next_ins; if (branch_ins) { - if (branch_ins->opcode == OP_COND_EXC_C || branch_ins->opcode == OP_COND_EXC_IC){ + if (branch_ins->opcode == OP_COND_EXC_C || branch_ins->opcode == OP_COND_EXC_IC) { // bltu rd, rs1, overflow branch_ins->opcode = OP_RISCV_EXC_BLTU; branch_ins->sreg1 = ins->dreg; branch_ins->sreg2 = ins->sreg1; - } - else if (branch_ins->opcode == OP_COND_EXC_OV || branch_ins->opcode == OP_COND_EXC_IOV) { + } else if (branch_ins->opcode == OP_COND_EXC_OV || branch_ins->opcode == OP_COND_EXC_IOV) { // bne t3, t4, overflow branch_ins->opcode = OP_RISCV_EXC_BNE; branch_ins->sreg1 = mono_alloc_ireg (cfg); @@ -3286,23 +3281,23 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) #else ins->opcode = OP_IMUL; #endif - break; + break; case OP_DIV_IMM: NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); temp->inst_l = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); #ifdef TARGET_RISCV64 - g_assert(mono_op_imm_to_op (ins->opcode) == OP_LDIV); + g_assert (mono_op_imm_to_op (ins->opcode) == OP_LDIV); #else - g_assert(mono_op_imm_to_op (ins->opcode) == OP_IDIV); + g_assert (mono_op_imm_to_op (ins->opcode) == OP_IDIV); #endif ins->opcode = mono_op_imm_to_op (ins->opcode); ins->sreg2 = temp->dreg; break; case OP_IMUL_IMM: case OP_LMUL_IMM: - case OP_IDIV_IMM: + case OP_IDIV_IMM: case OP_IREM_IMM: case OP_LREM_IMM: case OP_IREM_UN_IMM: @@ -3311,7 +3306,7 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) temp->inst_l = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); - g_assert(mono_op_imm_to_op (ins->opcode) != -1); + g_assert (mono_op_imm_to_op (ins->opcode) != -1); ins->opcode = GINT_TO_OPCODE (mono_op_imm_to_op (ins->opcode)); ins->sreg2 = temp->dreg; break; @@ -3334,12 +3329,12 @@ mono_arch_lowering_pass (MonoCompile *cfg, MonoBasicBlock *bb) case OP_ISHR_IMM: case OP_SHR_UN_IMM: case OP_ISHR_UN_IMM: - if (!RISCV_VALID_LS_AMOUNT (ins->inst_imm)){ + if (!RISCV_VALID_LS_AMOUNT (ins->inst_imm)) { NEW_INS_BEFORE (cfg, ins, temp, OP_I8CONST); temp->inst_l = ins->inst_imm; temp->dreg = mono_alloc_ireg (cfg); - g_assert(mono_op_imm_to_op (ins->opcode) != -1); + g_assert (mono_op_imm_to_op (ins->opcode) != -1); ins->opcode = GINT_TO_OPCODE (mono_op_imm_to_op (ins->opcode)); ins->sreg2 = temp->dreg; } @@ -4050,7 +4045,7 @@ static guint8 * mono_riscv_emit_branch_exc (MonoCompile *cfg, guint8 *code, int opcode, int sreg1, int sreg2, const char *exc_name) { riscv_auipc (code, MONO_ARCH_EXC_ADDR_REG, 0); - riscv_addi (code, MONO_ARCH_EXC_ADDR_REG, MONO_ARCH_EXC_ADDR_REG,8); + riscv_addi (code, MONO_ARCH_EXC_ADDR_REG, MONO_ARCH_EXC_ADDR_REG, 8); switch (opcode) { case OP_RISCV_EXC_BEQ: riscv_bne (code, sreg1, sreg2, 8); @@ -4443,8 +4438,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fclass_s (code, RISCV_T0, ins->sreg1); riscv_andi (code, RISCV_T0, RISCV_T0, ~(RISCV_FCLASS_INF | RISCV_FCLASS_NAN)); - code = mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BEQ, RISCV_T0, RISCV_ZERO, - "ArithmeticException"); + code = + mono_riscv_emit_branch_exc (cfg, code, OP_RISCV_EXC_BEQ, RISCV_T0, RISCV_ZERO, "ArithmeticException"); } case OP_BREAK: /* @@ -4820,7 +4815,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fence (code, RISCV_FENCE_R, RISCV_FENCE_MEM); break; } - case OP_ATOMIC_STORE_I1: + case OP_ATOMIC_STORE_I1: case OP_ATOMIC_STORE_U1: { riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_W); code = mono_riscv_emit_store (code, ins->sreg1, ins->inst_destbasereg, ins->inst_offset, 1); @@ -4828,7 +4823,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_MEM); break; } - case OP_ATOMIC_STORE_I2: + case OP_ATOMIC_STORE_I2: case OP_ATOMIC_STORE_U2: { riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_W); code = mono_riscv_emit_store (code, ins->sreg1, ins->inst_destbasereg, ins->inst_offset, 2); @@ -4836,7 +4831,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_MEM); break; } - case OP_ATOMIC_STORE_I4: + case OP_ATOMIC_STORE_I4: case OP_ATOMIC_STORE_U4: { riscv_fence (code, RISCV_FENCE_MEM, RISCV_FENCE_W); code = mono_riscv_emit_store (code, ins->sreg1, ins->inst_destbasereg, ins->inst_offset, 4); @@ -4982,7 +4977,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) riscv_fcvt_w_s (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); break; } - case OP_FCONV_TO_U4:{ + case OP_FCONV_TO_U4: { g_assert (riscv_stdext_f || riscv_stdext_d); if (riscv_stdext_d) riscv_fcvt_wu_d (code, RISCV_ROUND_TZ, ins->dreg, ins->sreg1); @@ -5081,61 +5076,61 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_TAILCALL_REG: case OP_TAILCALL_MEMBASE: { int target_reg = RISCV_T1; - call = (MonoCallInst*)ins; + call = (MonoCallInst *)ins; g_assert (!cfg->method->save_lmf); switch (ins->opcode) { - case OP_TAILCALL: - break; - case OP_TAILCALL_REG: - g_assert (ins->sreg1 != -1); - g_assert (ins->sreg1 != RISCV_T0); - g_assert (ins->sreg1 != RISCV_T1); - g_assert (ins->sreg1 != RISCV_RA); - g_assert (ins->sreg1 != RISCV_SP); - g_assert (ins->sreg1 != RISCV_FP); - riscv_addi (code, target_reg, ins->sreg1, 0); - break; - case OP_TAILCALL_MEMBASE: - g_assert (ins->sreg1 != -1); - g_assert (ins->sreg1 != RISCV_T0); - g_assert (ins->sreg1 != RISCV_T1); - g_assert (ins->sreg1 != RISCV_RA); - g_assert (ins->sreg1 != RISCV_SP); - g_assert (ins->sreg1 != RISCV_FP); - code = mono_riscv_emit_load (code, target_reg, ins->inst_basereg, ins->inst_offset, 0); - break; - default: - g_assert_not_reached (); + case OP_TAILCALL: + break; + case OP_TAILCALL_REG: + g_assert (ins->sreg1 != -1); + g_assert (ins->sreg1 != RISCV_T0); + g_assert (ins->sreg1 != RISCV_T1); + g_assert (ins->sreg1 != RISCV_RA); + g_assert (ins->sreg1 != RISCV_SP); + g_assert (ins->sreg1 != RISCV_FP); + riscv_addi (code, target_reg, ins->sreg1, 0); + break; + case OP_TAILCALL_MEMBASE: + g_assert (ins->sreg1 != -1); + g_assert (ins->sreg1 != RISCV_T0); + g_assert (ins->sreg1 != RISCV_T1); + g_assert (ins->sreg1 != RISCV_RA); + g_assert (ins->sreg1 != RISCV_SP); + g_assert (ins->sreg1 != RISCV_FP); + code = mono_riscv_emit_load (code, target_reg, ins->inst_basereg, ins->inst_offset, 0); + break; + default: + g_assert_not_reached (); } /* Restore registers */ code = mono_riscv_emit_load_stack (code, MONO_ARCH_CALLEE_SAVED_REGS & cfg->used_int_regs, RISCV_FP, - -cfg->arch.saved_gregs_offset, FALSE); + -cfg->arch.saved_gregs_offset, FALSE); /* Destroy frame */ code = mono_riscv_emit_destroy_frame (code); switch (ins->opcode) { - case OP_TAILCALL: - if(cfg->compile_aot){ - NOT_IMPLEMENTED; - } - else{ - mono_add_patch_info_rel (cfg, GPTRDIFF_TO_INT (code - cfg->native_code), MONO_PATCH_INFO_METHOD_JUMP, call->method, MONO_R_RISCV_JAL); - cfg->thunk_area += THUNK_SIZE; - riscv_jal (code, RISCV_ZERO, 0); - } - break; - case OP_TAILCALL_REG: - case OP_TAILCALL_MEMBASE: - // code = mono_arm_emit_brx (code, branch_reg); - riscv_jalr (code, RISCV_ZERO, target_reg, 0); - break; + case OP_TAILCALL: + if (cfg->compile_aot) { + NOT_IMPLEMENTED; + } else { + mono_add_patch_info_rel (cfg, GPTRDIFF_TO_INT (code - cfg->native_code), + MONO_PATCH_INFO_METHOD_JUMP, call->method, MONO_R_RISCV_JAL); + cfg->thunk_area += THUNK_SIZE; + riscv_jal (code, RISCV_ZERO, 0); + } + break; + case OP_TAILCALL_REG: + case OP_TAILCALL_MEMBASE: + // code = mono_arm_emit_brx (code, branch_reg); + riscv_jalr (code, RISCV_ZERO, target_reg, 0); + break; - default: - g_assert_not_reached (); + default: + g_assert_not_reached (); } ins->flags |= MONO_INST_GC_CALLSITE; diff --git a/src/mono/mono/mini/mini-riscv.h b/src/mono/mono/mini/mini-riscv.h index f791cc5b388be..36b092c122bb7 100644 --- a/src/mono/mono/mini/mini-riscv.h +++ b/src/mono/mono/mini/mini-riscv.h @@ -62,7 +62,7 @@ extern gboolean riscv_stdext_a, riscv_stdext_b, riscv_stdext_c, riscv_stdext_d, #define MONO_ARCH_CALLEE_REGS (0b11110000000000111111110000000000) #define MONO_ARCH_CALLEE_SAVED_REGS (0b00001111111111000000001100000000) #define MONO_ARCH_IS_CALLEE_SAVED_REG(reg) (MONO_ARCH_CALLEE_SAVED_REGS & (1 << (reg))) -#define MONO_ARCH_EXC_ADDR_REG (RISCV_T1) +#define MONO_ARCH_EXC_ADDR_REG (RISCV_T1) /** * callee saved regs + sp @@ -297,8 +297,10 @@ mono_riscv_throw_exception (gpointer arg, host_mgreg_t pc, host_mgreg_t *int_reg __attribute__ ((warn_unused_result)) guint8 * mono_riscv_emit_imm (guint8 *code, int rd, gsize imm); -__attribute__ ((warn_unused_result)) guint8 * -mono_riscv_emit_float_imm (guint8 *code, int rd, gsize f_imm, gboolean isSingle); +__attribute__ ((warn_unused_result)) guint8 *mono_riscv_emit_float_imm (guint8 *code, + int rd, + gsize f_imm, + gboolean isSingle); __attribute__ ((warn_unused_result)) guint8 *mono_riscv_emit_float_imm (guint8 *code, int rd, From 9b81d74a229aa9811ec3b591773c84c7e5b72060 Mon Sep 17 00:00:00 2001 From: Xinlong <821408745@qq.com> Date: Sat, 30 Dec 2023 15:25:30 +0800 Subject: [PATCH 135/139] remove format file --- src/mono/.clang-format | 81 ------------------------------------------ 1 file changed, 81 deletions(-) delete mode 100644 src/mono/.clang-format diff --git a/src/mono/.clang-format b/src/mono/.clang-format deleted file mode 100644 index c0a6e9b7f6798..0000000000000 --- a/src/mono/.clang-format +++ /dev/null @@ -1,81 +0,0 @@ ---- -Language: Cpp -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignConsecutiveMacros: true -AlignEscapedNewlinesLeft: false -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: true -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: false -AllowShortIfStatementsOnASingleLine: false -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterReturnType : AllDefinitions -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: true -BinPackArguments: true -BinPackParameters: false -BraceWrapping: - AfterClass: true - AfterControlStatement: true - AfterEnum: false - AfterFunction: true - AfterNamespace: false - AfterObjCDeclaration: false - AfterStruct: true - AfterUnion: true - BeforeCatch: true - BeforeElse: true - IndentBraces: false -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Linux -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: true -ColumnLimit: 120 -CommentPragmas: '^ IWYU pragma:' -ConstructorInitializerAllOnOneLineOrOnePerLine: true -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: true -DerivePointerAlignment: false -DisableFormat: false -ExperimentalAutoDetectBinPacking: false -ForEachMacros: [ ] -IndentCaseLabels: false -IndentWidth: 4 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -ObjCBlockIndentWidth: 2 -ObjCSpaceAfterProperty: false -ObjCSpaceBeforeProtocolList: true -PenaltyBreakBeforeFirstCallParameter: 400 -PenaltyBreakComment: 50 -PenaltyBreakFirstLessLess: 500 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 100000 -PointerAlignment: Right -ReflowComments: true -SortIncludes: false -SpaceAfterCStyleCast: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: Always -SpaceBeforeSquareBrackets: true -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: true -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: ForIndentation From 18bc0463a4841ad05d64eac84c1cbc397b1864ba Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Fri, 5 Jan 2024 11:58:15 +0800 Subject: [PATCH 136/139] Update issues.targets --- src/tests/issues.targets | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tests/issues.targets b/src/tests/issues.targets index d2a9dd249c12f..fa787effd3e86 100644 --- a/src/tests/issues.targets +++ b/src/tests/issues.targets @@ -3655,6 +3655,12 @@ + + + https://github.com/dotnet/runtime/issues/54906 + + + - - - - function dlopen at mono-dl.c:250 can't open the native lib libGCPollNative.so - - From 80ba68063210dc9e2dd4d6342af3d2de89816213 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Fri, 5 Jan 2024 11:58:48 +0800 Subject: [PATCH 137/139] Update src/mono/mono/mini/mini-ops.h Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com> --- src/mono/mono/mini/mini-ops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/mini-ops.h b/src/mono/mono/mini/mini-ops.h index 4108489d1beb1..ccdc1726a3025 100644 --- a/src/mono/mono/mini/mini-ops.h +++ b/src/mono/mono/mini/mini-ops.h @@ -1889,8 +1889,8 @@ MINI_OP(OP_RISCV_BGE, "riscv_bge", NONE, IREG, IREG) MINI_OP(OP_RISCV_BGEU, "riscv_bgeu", NONE, IREG, IREG) MINI_OP(OP_RISCV_BLT, "riscv_blt", NONE, IREG, IREG) MINI_OP(OP_RISCV_BLTU, "riscv_bltu", NONE, IREG, IREG) -MINI_OP (OP_RISCV_RBNAN, "riscv_r4_bnan", NONE, FREG, NONE) -MINI_OP (OP_RISCV_FBNAN, "riscv_float_bnan", NONE, FREG, NONE) +MINI_OP(OP_RISCV_RBNAN, "riscv_r4_bnan", NONE, FREG, NONE) +MINI_OP(OP_RISCV_FBNAN, "riscv_float_bnan", NONE, FREG, NONE) MINI_OP(OP_RISCV_ADDIW, "riscv_addiw", IREG, IREG, NONE) From 04bdc5f5ec791df724d62a0c202a43eb5841bc76 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Fri, 5 Jan 2024 12:18:52 +0800 Subject: [PATCH 138/139] fix compile error --- src/mono/mono/mini/mini-riscv.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index b88778efacce2..018c70f294110 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1503,11 +1503,13 @@ emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call, CallInfo *cinfo) { NOT_IMPLEMENTED; MonoMethodSignature *tmp_sig; - MonoInst *sig_arg; + int sig_reg; if (MONO_IS_TAILCALL_OPCODE (call)) NOT_IMPLEMENTED; + g_assert (cinfo->sig_cookie.storage == ArgOnStack); + /* * mono_ArgIterator_Setup assumes the signature cookie is * passed first and all the arguments which were before it are @@ -1520,10 +1522,8 @@ emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call, CallInfo *cinfo) memcpy (tmp_sig->params, call->signature->params + call->signature->sentinelpos, tmp_sig->param_count * sizeof (MonoType *)); - MONO_INST_NEW (cfg, sig_arg, OP_I8CONST); - sig_arg->dreg = mono_alloc_ireg (cfg); - sig_arg->inst_l = tmp_sig; - MONO_ADD_INS (cfg->cbb, sig_arg); + sig_reg = mono_alloc_ireg (cfg); + MONO_EMIT_NEW_SIGNATURECONST (cfg, sig_reg, tmp_sig); MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, RISCV_SP, cinfo->sig_cookie.offset, sig_arg->dreg); } From e2d132a63a3cb28982520bc8462a5abbc67ac424 Mon Sep 17 00:00:00 2001 From: VincentWu <43398706+Xinlong-Wu@users.noreply.github.com> Date: Fri, 5 Jan 2024 12:29:10 +0800 Subject: [PATCH 139/139] Update mini-riscv.c --- src/mono/mono/mini/mini-riscv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/mini-riscv.c b/src/mono/mono/mini/mini-riscv.c index 018c70f294110..afaa6838dd27f 100644 --- a/src/mono/mono/mini/mini-riscv.c +++ b/src/mono/mono/mini/mini-riscv.c @@ -1525,7 +1525,7 @@ emit_sig_cookie (MonoCompile *cfg, MonoCallInst *call, CallInfo *cinfo) sig_reg = mono_alloc_ireg (cfg); MONO_EMIT_NEW_SIGNATURECONST (cfg, sig_reg, tmp_sig); - MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, RISCV_SP, cinfo->sig_cookie.offset, sig_arg->dreg); + MONO_EMIT_NEW_STORE_MEMBASE (cfg, OP_STORE_MEMBASE_REG, RISCV_SP, cinfo->sig_cookie.offset, sig_reg); } /**