[Mono] [RISCV] Fix abi issues (Monthly pr) (#88649)
authorVincentWu <43398706+Xinlong-Wu@users.noreply.github.com>
Mon, 24 Jul 2023 01:17:07 +0000 (11:17 +1000)
committerGitHub <noreply@github.com>
Mon, 24 Jul 2023 01:17:07 +0000 (21:17 -0400)
commit08aba6922a11e92fc7a67ea5e3340cab8bceb36d
treec4cb6f49622d5643c93ff54a7388fc14bd6fa086
parentfe03904c5c374aca8a82356d095f58b710fdacde
[Mono] [RISCV] Fix abi issues (Monthly pr) (#88649)

* update makefile

* add format file

* use mul inst instead of emulate mul
process stack size larger than imm32

* emit get_throw_trampoline

* mono_riscv_throw_exception

* fix error of stack trace

* test case

* output inst idiv
fix mono_riscv_emit_branch_exc

* implement mono_arch_get_throw_corlib_exception

* fix rdiv

* move ArgOnStack arg at prologue
lowering OP_XOR_IMM&OP_IXOR_IMM

* fix emit_imm

* test imm

* update test case

* use swich to process return value

* fix unwind inst def_cfa

* fmt

* lowering OP_LMUL_IMM

* make file for webapiclient

* lowerng&output
- OP_FCONV_TO_I8
- OP_LXOR_IMM
- OP_ISHR

* lowerng&output
- relaxed_nop
- float_cle
- long_shl
- OP_ICONV_TO_R_UN
- OP_LCONV_TO_I2
- OP_FBGE
- OP_IDIV_IMM

* fix this_pointer in vcall with valuetype returned
- The ABI specify that If the reture value would have been passed by reference, the caller will allocates memory for the return value, and passes the address as an implicit first parameter.
- The Mono will treat first parameter as this_pointer reference to `mono_vcall_trampoline()`.  They are conflict a bit.

* process param type: ArgVtypeOnStack & ArgVtypeByRef

* lowering OP_LCONV_TO_I2

* OP_IREM_UN_IMM
OP_ATOMIC_LOAD_U1
OP_IREM_UN_IMM

* fix output of OP_IREM & OP_IREM_UN
OP_IREM -> riscv_remw
OP_IREM_UN -> riscv_remuw

* use `lw` to load u4 value on the stack
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#integer-calling-convention

* optmise lw+zext -> lwu

* fix patch_full
use mono_riscv_emit_loadu to emit lwu
fix rem

* fix `mono_arch_build_imt_trampoline` when `item->is_equals==false`

* FIXME: reg got crashed wetween `this` and return ref

* fix `mono_arch_build_imt_trampoline`

* float_sub & float_div

* OP_FNEG,OP_LADD_OVF,OP_FBEQ, OP_COND_EXC_OV

* fix mono_arch_emit_outarg_vt

* process ArgVtypeOnStack in emit_move_args

* add sample status

* fix valid imm check of OP_L.*_IMM

* OP_LCONV_TO_R_UN

* update

* fix the param order stored o stack

* fix the param size of MONO_TYPE_I & MONO_TYPE_U when RV64

* add test task for makefile

* update .clang-format

* fmt

* fix merge

* TMP

* clean pr

* keep  this_pointer always be RISCV_A0
src/mono/mono/mini/cpu-riscv64.mdesc
src/mono/mono/mini/mini-riscv.c
src/mono/mono/mini/mini-riscv.h
src/mono/mono/mini/mini.c
src/mono/mono/mini/tramp-riscv.c