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

[LoongArch64] Part-3:add method trampolines module for LoongArch64. #21766

Merged
merged 1 commit into from
May 13, 2024
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
92 changes: 92 additions & 0 deletions mono/mini/mini-loongarch64-gsharedvt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* \file
* gsharedvt support code for loongarch64.
*
* Authors:
* Qiao Pengcheng (qiaopengcheng@loongson.cn), Liu An(liuan@loongson.cn)
*
* Copyright (c) 2021 Loongson Technology, Inc
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "mini.h"
#include "mini-loongarch64.h"
#include "mini-loongarch64-gsharedvt.h"
#include "aot-runtime.h"

/*
* GSHAREDVT
*/
#ifdef MONO_ARCH_GSHAREDVT_SUPPORTED

void
mono_loongarch_gsharedvt_init (void)
{
}

gboolean
mono_arch_gsharedvt_sig_supported (MonoMethodSignature *sig)
{
/*
if (sig->ret && is_variable_size (sig->ret))
return FALSE;
*/
return TRUE;
}

static void
add_to_map (GPtrArray *map, int src, int dst)
{
g_ptr_array_add (map, GUINT_TO_POINTER (src));
g_ptr_array_add (map, GUINT_TO_POINTER (dst));
}

/*
* Slot mapping:
* 0..8 - r0..r8
* 9..16 - d0..d7
* 17.. - stack slots
*/

static int
map_reg (int reg)
{
return reg;
}

static int
map_freg (int reg)
{
return reg + NUM_GSHAREDVT_ARG_GREGS;
}

static int
map_stack_slot (int slot)
{
return slot + NUM_GSHAREDVT_ARG_GREGS + NUM_GSHAREDVT_ARG_FREGS;
}

static int
get_arg_slots (ArgInfo *ainfo, int **out_slots)
{
return 0;
}

/*
* mono_arch_get_gsharedvt_call_info:
*
* See mini-x86.c for documentation.
*/
gpointer
mono_arch_get_gsharedvt_call_info (gpointer addr, MonoMethodSignature *normal_sig, MonoMethodSignature *gsharedvt_sig, gboolean gsharedvt_in, gint32 vcall_offset, gboolean calli)
{
return NULL;
}

#else

void
mono_loongarch_gsharedvt_init (void)
{
}

#endif /* MONO_ARCH_GSHAREDVT_SUPPORTED */
88 changes: 88 additions & 0 deletions mono/mini/mini-loongarch64-gsharedvt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* \file
*/

#ifndef __MINI_LOONGARCH64_GSHAREDVT_H__
#define __MINI_LOONGARCH64_GSHAREDVT_H__

/* Argument marshallings for calls between gsharedvt and normal code */
typedef enum {
GSHAREDVT_ARG_NONE = 0,
GSHAREDVT_ARG_BYVAL_TO_BYREF = 1,
GSHAREDVT_ARG_BYVAL_TO_BYREF_HFAR4 = 2,
GSHAREDVT_ARG_BYREF_TO_BYVAL = 3,
GSHAREDVT_ARG_BYREF_TO_BYVAL_HFAR4 = 4,
GSHAREDVT_ARG_BYREF_TO_BYREF = 5
} GSharedVtArgMarshal;

/* For arguments passed on the stack on ios */
typedef enum {
GSHAREDVT_ARG_SIZE_NONE = 0,
GSHAREDVT_ARG_SIZE_I1 = 1,
GSHAREDVT_ARG_SIZE_U1 = 2,
GSHAREDVT_ARG_SIZE_I2 = 3,
GSHAREDVT_ARG_SIZE_U2 = 4,
GSHAREDVT_ARG_SIZE_I4 = 5,
GSHAREDVT_ARG_SIZE_U4 = 6,
} GSharedVtArgSize;

/* Return value marshalling for calls between gsharedvt and normal code */
typedef enum {
GSHAREDVT_RET_NONE = 0,
GSHAREDVT_RET_I8 = 1,
GSHAREDVT_RET_I1 = 2,
GSHAREDVT_RET_U1 = 3,
GSHAREDVT_RET_I2 = 4,
GSHAREDVT_RET_U2 = 5,
GSHAREDVT_RET_I4 = 6,
GSHAREDVT_RET_U4 = 7,
GSHAREDVT_RET_R8 = 8,
GSHAREDVT_RET_R4 = 9,
GSHAREDVT_RET_IREGS_1 = 10,
GSHAREDVT_RET_IREGS_2 = 11,
GSHAREDVT_RET_IREGS_3 = 12,
GSHAREDVT_RET_IREGS_4 = 13,
GSHAREDVT_RET_IREGS_5 = 14,
GSHAREDVT_RET_IREGS_6 = 15,
GSHAREDVT_RET_IREGS_7 = 16,
GSHAREDVT_RET_IREGS_8 = 17,
GSHAREDVT_RET_HFAR8_1 = 18,
GSHAREDVT_RET_HFAR8_2 = 19,
GSHAREDVT_RET_HFAR8_3 = 20,
GSHAREDVT_RET_HFAR8_4 = 21,
GSHAREDVT_RET_HFAR4_1 = 22,
GSHAREDVT_RET_HFAR4_2 = 23,
GSHAREDVT_RET_HFAR4_3 = 24,
GSHAREDVT_RET_HFAR4_4 = 25,
GSHAREDVT_RET_NUM = 26
} GSharedVtRetMarshal;

typedef struct {
/* Method address to call */
gpointer addr;
/* The trampoline reads this, so keep the size explicit */
int ret_marshal;
/* If ret_marshal != NONE, this is the reg of the vret arg, else -1 */
/* Equivalent of vret_arg_slot in x86 implementation. */
int vret_arg_reg;
/* The stack slot where the return value will be stored */
int vret_slot;
int stack_usage, map_count;
/* If not -1, then make a virtual call using this vtable offset */
int vcall_offset;
/* If 1, make an indirect call to the address in the rgctx reg */
int calli;
/* Whenever this is a in or an out call */
int gsharedvt_in;
/* Maps stack slots/registers in the caller to the stack slots/registers in the callee */
int map [MONO_ZERO_LEN_ARRAY];
} GSharedVtCallInfo;

/* Number of argument registers (r0..r8) */
#define NUM_GSHAREDVT_ARG_GREGS 9
#define NUM_GSHAREDVT_ARG_FREGS 8

gpointer
mono_loongarch_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpointer *callee, gpointer mrgctx_reg);

#endif /* __MINI_LOONGARCH64_GSHAREDVT_H__ */
59 changes: 59 additions & 0 deletions mono/mini/tramp-loongarch64-gsharedvt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* \file
* gsharedvt support code for loongarch64.
*
* Authors:
* Qiao Pengcheng (qiaopengcheng@loongson.cn), Liu An(liuan@loongson.cn)
*
* Copyright (c) 2021 Loongson Technology, Inc
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <mono/metadata/abi-details.h>

#include "mini.h"
#include "mini-loongarch64.h"
#include "mini-loongarch64-gsharedvt.h"
#include "mini-runtime.h"

/*
* GSHAREDVT
*/
#ifdef MONO_ARCH_GSHAREDVT_SUPPORTED

/*
* mono_arch_get_gsharedvt_arg_trampoline:
*
* See tramp-x86.c for documentation.
*/
gpointer
mono_arch_get_gsharedvt_arg_trampoline (MonoDomain *domain, gpointer arg, gpointer addr)
{
return NULL;
}

gpointer
mono_loongarch_start_gsharedvt_call (GSharedVtCallInfo *info, gpointer *caller, gpointer *callee, gpointer mrgctx_reg)
{
return NULL;
}

#ifndef DISABLE_JIT

gpointer
mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot)
{
return NULL;
}

#else

gpointer
mono_arch_get_gsharedvt_trampoline (MonoTrampInfo **info, gboolean aot)
{
g_assert_not_reached ();
return NULL;
}

#endif

#endif /* MONO_ARCH_GSHAREDVT_SUPPORTED */
Loading
Loading