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] coreclr-jit directory #82379

Merged
merged 27 commits into from
Apr 8, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
15cf55b
[RISCV-V] coreclr-jit directory
clamp03 Oct 26, 2022
f4aa536
Fix in jit/CMakeLists.txt
clamp03 Feb 20, 2023
37f9519
Tidy up by jit-format
clamp03 Feb 20, 2023
f3a7a41
Add a emitIns_S_R_R to handling more temporary reg
clamp03 Feb 21, 2023
521db1c
Fix jit code format
clamp03 Feb 21, 2023
48c198c
Fix
clamp03 Mar 7, 2023
8760646
[JIT] Fix test
clamp03 Mar 7, 2023
60d461d
[JIT] Updated
clamp03 Mar 8, 2023
d18dba2
[JIT] JitFormat
clamp03 Mar 8, 2023
2ed1f9c
[JIT] Enable IsImplicitByrefParameterValuePostMorph
clamp03 Mar 8, 2023
d78f857
[JIT] Update
clamp03 Mar 9, 2023
ffb1eb6
Merge remote-tracking branch 'upstream/main' into riscv_jit
clamp03 Mar 10, 2023
6c4b302
[JIT] Replace to RISCV64
clamp03 Mar 15, 2023
30591c9
[JIT] Update emitter and fix bugs
clamp03 Mar 22, 2023
2cff93e
[JIT] Fix a build error (remove GT_ADDR)
clamp03 Apr 3, 2023
b8d92e1
[JIT] FIX BUILD ERROR
clamp03 Apr 4, 2023
618978a
[JIT] Update by reviews
clamp03 Apr 5, 2023
cec6fa0
[JIT] Update JCMP and fix related errors
clamp03 Apr 5, 2023
db341cc
[JIT] Add NYI
clamp03 Apr 5, 2023
607dd64
[JIT] Add getRISCV64PassStructInRegisterFlags
clamp03 Apr 6, 2023
6492c51
[JIT] Remove constant handling in genRangeCheck
clamp03 Apr 6, 2023
f06eef5
[VM] Add getRISCV64PassStructInRegisterFlags
clamp03 Apr 6, 2023
672629a
[VM] Update JITEEVersionIdentifier
clamp03 Apr 6, 2023
f25d760
Merge remote-tracking branch 'upstream/main' into riscv_jit
clamp03 Apr 6, 2023
718b6d9
Run jit-format
jakobbotsch Apr 6, 2023
b94ebc5
Merge branch 'main' of github.com:dotnet/runtime into pr-82379
jakobbotsch Apr 8, 2023
f39aaa3
Fix after merge
jakobbotsch Apr 8, 2023
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
45 changes: 35 additions & 10 deletions src/coreclr/jit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ function(create_standalone_jit)
elseif(TARGETDETAILS_ARCH STREQUAL "loongarch64")
set(JIT_ARCH_SOURCES ${JIT_LOONGARCH64_SOURCES})
set(JIT_ARCH_HEADERS ${JIT_LOONGARCH64_HEADERS})
elseif(TARGETDETAILS_ARCH STREQUAL "riscv64")
set(JIT_ARCH_SOURCES ${JIT_RISCV64_SOURCES})
set(JIT_ARCH_HEADERS ${JIT_RISCV64_HEADERS})
else()
clr_unknown_arch()
endif()
Expand Down Expand Up @@ -259,6 +262,15 @@ set( JIT_LOONGARCH64_SOURCES
unwindloongarch64.cpp
)

set( JIT_RISCV64_SOURCES
codegenriscv64.cpp
emitriscv64.cpp
lowerriscv64.cpp
lsrariscv64.cpp
targetriscv64.cpp
unwindriscv64.cpp
)

# We include the headers here for better experience in IDEs.
set( JIT_HEADERS
../inc/corinfo.h
Expand Down Expand Up @@ -417,6 +429,13 @@ set( JIT_LOONGARCH64_HEADERS
registerloongarch64.h
)

set( JIT_RISCV64_HEADERS
emitriscv64.h
emitfmtsriscv64.h
instrsriscv64.h
registerriscv64.h
)

convert_to_absolute_path(JIT_SOURCES ${JIT_SOURCES})
convert_to_absolute_path(JIT_HEADERS ${JIT_HEADERS})
convert_to_absolute_path(JIT_RESOURCES ${JIT_RESOURCES})
Expand All @@ -437,6 +456,8 @@ convert_to_absolute_path(JIT_S390X_SOURCES ${JIT_S390X_SOURCES})
convert_to_absolute_path(JIT_S390X_HEADERS ${JIT_S390X_HEADERS})
convert_to_absolute_path(JIT_LOONGARCH64_SOURCES ${JIT_LOONGARCH64_SOURCES})
convert_to_absolute_path(JIT_LOONGARCH64_HEADERS ${JIT_LOONGARCH64_HEADERS})
convert_to_absolute_path(JIT_RISCV64_SOURCES ${JIT_RISCV64_SOURCES})
convert_to_absolute_path(JIT_RISCV64_HEADERS ${JIT_RISCV64_HEADERS})

if(CLR_CMAKE_TARGET_ARCH_AMD64)
set(JIT_ARCH_SOURCES ${JIT_AMD64_SOURCES})
Expand All @@ -463,6 +484,8 @@ elseif(CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
set(JIT_ARCH_SOURCES ${JIT_LOONGARCH64_SOURCES})
set(JIT_ARCH_HEADERS ${JIT_LOONGARCH64_HEADERS})
elseif(CLR_CMAKE_TARGET_ARCH_RISCV64)
set(JIT_ARCH_SOURCES ${JIT_RISCV64_SOURCES})
set(JIT_ARCH_HEADERS ${JIT_RISCV64_HEADERS})
else()
clr_unknown_arch()
endif()
Expand Down Expand Up @@ -593,10 +616,8 @@ else()
set(TARGET_OS_NAME win)
endif()

if (NOT CLR_CMAKE_TARGET_ARCH_RISCV64)
create_standalone_jit(TARGET clrjit OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME} DESTINATIONS . sharedFramework)
install_clr(TARGETS clrjit DESTINATIONS . sharedFramework COMPONENT jit)
endif()
create_standalone_jit(TARGET clrjit OS ${TARGET_OS_NAME} ARCH ${ARCH_TARGET_NAME} DESTINATIONS . sharedFramework)
install_clr(TARGETS clrjit DESTINATIONS . sharedFramework COMPONENT jit)

# Enable profile guided optimization
add_pgo(clrjit)
Expand All @@ -611,22 +632,26 @@ if (CLR_CMAKE_TARGET_ARCH_LOONGARCH64)
create_standalone_jit(TARGET clrjit_unix_loongarch64_${ARCH_HOST_NAME} OS unix ARCH loongarch64 DESTINATIONS .)
endif (CLR_CMAKE_TARGET_ARCH_LOONGARCH64)

create_standalone_jit(TARGET clrjit_universal_arm_${ARCH_HOST_NAME} OS universal ARCH arm DESTINATIONS .)
target_compile_definitions(clrjit_universal_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP CONFIGURABLE_ARM_ABI)
create_standalone_jit(TARGET clrjit_win_x86_${ARCH_HOST_NAME} OS win ARCH x86 DESTINATIONS .)
if (CLR_CMAKE_TARGET_ARCH_RISCV64)
create_standalone_jit(TARGET clrjit_unix_riscv64_${ARCH_HOST_NAME} OS unix ARCH riscv64 DESTINATIONS .)
else()
create_standalone_jit(TARGET clrjit_universal_arm_${ARCH_HOST_NAME} OS universal ARCH arm DESTINATIONS .)
target_compile_definitions(clrjit_universal_arm_${ARCH_HOST_NAME} PRIVATE ARM_SOFTFP CONFIGURABLE_ARM_ABI)
create_standalone_jit(TARGET clrjit_win_x86_${ARCH_HOST_NAME} OS win ARCH x86 DESTINATIONS .)
endif (CLR_CMAKE_TARGET_ARCH_RISCV64)

if (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)
create_standalone_jit(TARGET clrjit_unix_x86_${ARCH_HOST_NAME} OS unix ARCH x86 DESTINATIONS .)
endif (CLR_CMAKE_TARGET_ARCH_I386 AND CLR_CMAKE_TARGET_UNIX)

if (CLR_CMAKE_TARGET_UNIX AND NOT CLR_CMAKE_TARGET_ARCH_RISCV64)
if (NOT ARCH_TARGET_NAME STREQUAL s390x AND NOT ARCH_TARGET_NAME STREQUAL armv6 AND NOT ARCH_TARGET_NAME STREQUAL ppc64le)
if (CLR_CMAKE_TARGET_UNIX)
if (NOT ARCH_TARGET_NAME STREQUAL s390x AND NOT ARCH_TARGET_NAME STREQUAL armv6 AND NOT ARCH_TARGET_NAME STREQUAL ppc64le AND NOT ARCH_TARGET_NAME STREQUAL riscv64)
if(CLR_CMAKE_TARGET_ARCH_ARM OR CLR_CMAKE_TARGET_ARCH_ARM64)
install_clr(TARGETS clrjit_universal_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit)
else()
install_clr(TARGETS clrjit_unix_${ARCH_TARGET_NAME}_${ARCH_HOST_NAME} DESTINATIONS . COMPONENT jit)
endif()
endif(NOT ARCH_TARGET_NAME STREQUAL s390x AND NOT ARCH_TARGET_NAME STREQUAL armv6 AND NOT ARCH_TARGET_NAME STREQUAL ppc64le)
endif(NOT ARCH_TARGET_NAME STREQUAL s390x AND NOT ARCH_TARGET_NAME STREQUAL armv6 AND NOT ARCH_TARGET_NAME STREQUAL ppc64le AND NOT ARCH_TARGET_NAME STREQUAL riscv64)
endif()

if (CLR_CMAKE_TARGET_WIN32 AND CLR_CMAKE_PGO_INSTRUMENT)
Expand Down
42 changes: 31 additions & 11 deletions src/coreclr/jit/codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class CodeGen final : public CodeGenInterface

void genJumpToThrowHlpBlk(emitJumpKind jumpKind, SpecialCodeKind codeKind, BasicBlock* failBlk = nullptr);

#ifdef TARGET_LOONGARCH64
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
void genJumpToThrowHlpBlk_la(SpecialCodeKind codeKind,
instruction ins,
regNumber reg1,
Expand All @@ -257,7 +257,7 @@ class CodeGen final : public CodeGenInterface
//

void genEstablishFramePointer(int delta, bool reportUnwindData);
#if defined(TARGET_LOONGARCH64)
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
void genFnPrologCalleeRegArgs();
#else
void genFnPrologCalleeRegArgs(regNumber xtraReg, bool* pXtraRegClobbered, RegState* regState);
Expand All @@ -273,7 +273,7 @@ class CodeGen final : public CodeGenInterface
void genClearStackVec3ArgUpperBits();
#endif // UNIX_AMD64_ABI && FEATURE_SIMD

#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
bool genInstrWithConstant(instruction ins,
emitAttr attr,
regNumber reg1,
Expand Down Expand Up @@ -437,7 +437,27 @@ class CodeGen final : public CodeGenInterface
};

FuncletFrameInfoDsc genFuncletInfo;
#endif // TARGET_LOONGARCH64

#elif defined(TARGET_RISCV64)

// A set of information that is used by funclet prolog and epilog generation.
// It is collected once, before funclet prologs and epilogs are generated,
// and used by all funclet prologs and epilogs, which must all be the same.
struct FuncletFrameInfoDsc
{
regMaskTP fiSaveRegs; // Set of callee-saved registers saved in the funclet prolog (includes RA)
int fiFunction_CallerSP_to_FP_delta; // Delta between caller SP and the frame pointer in the parent function
// (negative)
int fiSP_to_FPRA_save_delta; // FP/RA register save offset from SP (positive)
int fiSP_to_PSP_slot_delta; // PSP slot offset from SP (positive)
int fiCallerSP_to_PSP_slot_delta; // PSP slot offset from Caller SP (negative)
int fiFrameType; // Funclet frame types are numbered. See genFuncletProlog() for details.
int fiSpDelta1; // Stack pointer delta 1 (negative)
};

FuncletFrameInfoDsc genFuncletInfo;

#endif // TARGET_ARM, TARGET_ARM64, TARGET_AMD64, TARGET_LOONGARCH64, TARGET_RISCV64

#if defined(TARGET_XARCH)

Expand Down Expand Up @@ -780,9 +800,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void genLeaInstruction(GenTreeAddrMode* lea);
void genSetRegToCond(regNumber dstReg, GenTree* tree);

#if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
void genScaledAdd(emitAttr attr, regNumber targetReg, regNumber baseReg, regNumber indexReg, int scale);
#endif // TARGET_ARMARCH || TARGET_LOONGARCH64
#endif // TARGET_ARMARCH || TARGET_LOONGARCH64 || TARGET_RISCV64

#if defined(TARGET_ARMARCH)
void genCodeForMulLong(GenTreeOp* mul);
Expand Down Expand Up @@ -1206,7 +1226,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void genTableBasedSwitch(GenTree* tree);
void genCodeForArrIndex(GenTreeArrIndex* treeNode);
void genCodeForArrOffset(GenTreeArrOffs* treeNode);
#if defined(TARGET_LOONGARCH64)
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
instruction genGetInsForOper(GenTree* treeNode);
#else
instruction genGetInsForOper(genTreeOps oper, var_types type);
Expand All @@ -1218,7 +1238,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void genCallInstruction(GenTreeCall* call X86_ARG(target_ssize_t stackArgBytes));
void genJmpMethod(GenTree* jmp);
BasicBlock* genCallFinally(BasicBlock* block);
#if defined(TARGET_LOONGARCH64)
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
// TODO: refactor for LA.
void genCodeForJumpCompare(GenTreeOp* tree);
#endif
Expand Down Expand Up @@ -1252,9 +1272,9 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
void genFloatReturn(GenTree* treeNode);
#endif // TARGET_X86

#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
void genSimpleReturn(GenTree* treeNode);
#endif // TARGET_ARM64 || TARGET_LOONGARCH64
#endif // TARGET_ARM64 || TARGET_LOONGARCH64 || TARGET_RISCV64

void genReturn(GenTree* treeNode);

Expand Down Expand Up @@ -1563,7 +1583,7 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
static instruction JumpKindToCmov(emitJumpKind condition);
#endif

#ifndef TARGET_LOONGARCH64
#if !defined(TARGET_LOONGARCH64)
// Maps a GenCondition code to a sequence of conditional jumps or other conditional instructions
// such as X86's SETcc. A sequence of instructions rather than just a single one is required for
// certain floating point conditions.
Expand Down
Loading