Skip to content

Commit

Permalink
[RISC-V] Port Mono for RISC-V 64 Arch (1/3) lp64d ABI (#83714)
Browse files Browse the repository at this point in the history
* support abi lp64d for RISC-V 64

* format
  • Loading branch information
Xinlong-Wu authored Apr 3, 2023
1 parent 730a030 commit c0b05ae
Show file tree
Hide file tree
Showing 6 changed files with 1,608 additions and 64 deletions.
2 changes: 1 addition & 1 deletion src/mono/mono.proj
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@
<_Objcopy Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/bin/llvm-objcopy</_Objcopy>
<_Objcopy Condition="'$(TargetsLinuxMusl)' == 'true' and '$(CrossBuild)' != 'true'">objcopy</_Objcopy>

<_ObjcopyPrefix Condition="'$(MonoCrossDir)' != '' and '$(Platform)' == 'riscv64'">llvm-objcopy-</_ObjcopyPrefix>
<_ObjcopyPrefix Condition="'$(MonoCrossDir)' != '' and '$(Platform)' == 'riscv64' and $(_Objcopy) == ''">llvm-objcopy-</_ObjcopyPrefix>
</PropertyGroup>
<!-- test viability of objcopy command -->
<Exec Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true' and ('$(TargetsLinux)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true')" Command="$(_Objcopy) -V" IgnoreStandardErrorWarningFormat="true" ContinueOnError="WarnAndContinue" IgnoreExitCode="true" EchoOff="true" ConsoleToMsBuild="true">
Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/arch/riscv/riscv-codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,8 @@ enum {
(RISCV_BITS ((ins), 12, 8) << 12) | (RISCV_SIGN ((ins)) << 20))

// Check a value for validity as an immediate.

#define RISCV_VALID_IMM(value) \
(((gint32)value) == (value))
#define RISCV_VALID_I_IMM(value) \
(RISCV_DECODE_I_IMM (RISCV_ENCODE_I_IMM ((value))) == (value))
#define RISCV_VALID_S_IMM(value) \
Expand Down
10 changes: 10 additions & 0 deletions src/mono/mono/metadata/object-offsets.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ DECL_OFFSET(MonoLMF, eip)
DECL_OFFSET(MonoLMF, gregs)
DECL_OFFSET(MonoLMF, fregs)
#elif defined(TARGET_RISCV)
DECL_OFFSET(MonoLMF, lmf_addr)
DECL_OFFSET(MonoLMF, pc)
DECL_OFFSET(MonoLMF, gregs)
DECL_OFFSET(MonoContext, gregs)
DECL_OFFSET(MonoContext, fregs)
#endif
Expand Down Expand Up @@ -314,6 +317,13 @@ DECL_OFFSET(CallContext, stack_size)
DECL_OFFSET(CallContext, stack)
#endif

#if defined(TARGET_RISCV)
DECL_OFFSET(CallContext, gregs)
DECL_OFFSET(CallContext, fregs)
DECL_OFFSET(CallContext, stack_size)
DECL_OFFSET(CallContext, stack)
#endif

#if defined(TARGET_X86)
DECL_OFFSET(GSharedVtCallInfo, stack_usage)
DECL_OFFSET(GSharedVtCallInfo, vret_slot)
Expand Down
4 changes: 4 additions & 0 deletions src/mono/mono/mini/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ static const gint16 opidx [] = {

#endif

#ifdef TARGET_RISCV64
#define ARCH_PREFIX "riscv64-linux-gnu-"
#else
#define ARCH_PREFIX ""
#endif
//#define ARCH_PREFIX "powerpc64-linux-gnu-"

const char*
Expand Down
Loading

0 comments on commit c0b05ae

Please sign in to comment.