Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RISC-V] Port Mono for RISC-V 64 Arch (1/3) lp64d ABI #83714

Merged
merged 4 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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