Skip to content

Commit c0b05ae

Browse files
authored
[RISC-V] Port Mono for RISC-V 64 Arch (1/3) lp64d ABI (#83714)
* support abi lp64d for RISC-V 64 * format
1 parent 730a030 commit c0b05ae

File tree

6 files changed

+1608
-64
lines changed

6 files changed

+1608
-64
lines changed

src/mono/mono.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@
656656
<_Objcopy Condition="'$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true'">$(ANDROID_NDK_ROOT)/toolchains/llvm/prebuilt/$(MonoToolchainPrebuiltOS)/bin/llvm-objcopy</_Objcopy>
657657
<_Objcopy Condition="'$(TargetsLinuxMusl)' == 'true' and '$(CrossBuild)' != 'true'">objcopy</_Objcopy>
658658

659-
<_ObjcopyPrefix Condition="'$(MonoCrossDir)' != '' and '$(Platform)' == 'riscv64'">llvm-objcopy-</_ObjcopyPrefix>
659+
<_ObjcopyPrefix Condition="'$(MonoCrossDir)' != '' and '$(Platform)' == 'riscv64' and $(_Objcopy) == ''">llvm-objcopy-</_ObjcopyPrefix>
660660
</PropertyGroup>
661661
<!-- test viability of objcopy command -->
662662
<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">

src/mono/mono/arch/riscv/riscv-codegen.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ enum {
293293
(RISCV_BITS ((ins), 12, 8) << 12) | (RISCV_SIGN ((ins)) << 20))
294294

295295
// Check a value for validity as an immediate.
296-
296+
#define RISCV_VALID_IMM(value) \
297+
(((gint32)value) == (value))
297298
#define RISCV_VALID_I_IMM(value) \
298299
(RISCV_DECODE_I_IMM (RISCV_ENCODE_I_IMM ((value))) == (value))
299300
#define RISCV_VALID_S_IMM(value) \

src/mono/mono/metadata/object-offsets.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ DECL_OFFSET(MonoLMF, eip)
255255
DECL_OFFSET(MonoLMF, gregs)
256256
DECL_OFFSET(MonoLMF, fregs)
257257
#elif defined(TARGET_RISCV)
258+
DECL_OFFSET(MonoLMF, lmf_addr)
259+
DECL_OFFSET(MonoLMF, pc)
260+
DECL_OFFSET(MonoLMF, gregs)
258261
DECL_OFFSET(MonoContext, gregs)
259262
DECL_OFFSET(MonoContext, fregs)
260263
#endif
@@ -314,6 +317,13 @@ DECL_OFFSET(CallContext, stack_size)
314317
DECL_OFFSET(CallContext, stack)
315318
#endif
316319

320+
#if defined(TARGET_RISCV)
321+
DECL_OFFSET(CallContext, gregs)
322+
DECL_OFFSET(CallContext, fregs)
323+
DECL_OFFSET(CallContext, stack_size)
324+
DECL_OFFSET(CallContext, stack)
325+
#endif
326+
317327
#if defined(TARGET_X86)
318328
DECL_OFFSET(GSharedVtCallInfo, stack_usage)
319329
DECL_OFFSET(GSharedVtCallInfo, vret_slot)

src/mono/mono/mini/helpers.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ static const gint16 opidx [] = {
6969

7070
#endif
7171

72+
#ifdef TARGET_RISCV64
73+
#define ARCH_PREFIX "riscv64-linux-gnu-"
74+
#else
7275
#define ARCH_PREFIX ""
76+
#endif
7377
//#define ARCH_PREFIX "powerpc64-linux-gnu-"
7478

7579
const char*

0 commit comments

Comments
 (0)