Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
da21fa4
[WIP] RISCV64 REL BUILD
clamp03 Oct 26, 2022
9ff3bdc
[WIP] RISCV64 DBG BUILD
clamp03 Nov 8, 2022
499e598
[WIP] FIX
clamp03 Nov 8, 2022
7433745
[WIP] FIX WHAT I DID FOR THREAD STORE TEST
clamp03 Nov 10, 2022
7587b73
[WIP] UPDATE ASSEMBLY FUNCTIONS and ADD CRASH TO UNIMPLEMENTED
clamp03 Nov 10, 2022
c7bd561
[WIP] UPDATE CRTHELPERS
clamp03 Nov 10, 2022
4ca0934
[WIP] UPDATE EXCEPTIONHANDLER AND CALLDESCRWORKERRISCV64
clamp03 Nov 10, 2022
8bdde90
[WIP] UPDATE ACTIVATIONHANDLERWRAPPER
clamp03 Nov 10, 2022
260fdc4
[WIP] CALLSIGNALHANDLEWRAPPER
clamp03 Nov 10, 2022
de1c03e
[WIP] FLOATCONVERSION, DBGHELPERS
clamp03 Nov 10, 2022
1a45b75
[WIP] PAL, ASMCONSTANTS, CONTEXT2
clamp03 Nov 11, 2022
da10fc8
[WIP] REMOVE ACTIVATIONHANDLERWRAPPER, DISPATCHEXCEPTIONWRAPPER
clamp03 Nov 11, 2022
0cb6eb6
[WIP] ADD CRASH INSTRS FOR UNINPLEMENTED
clamp03 Nov 11, 2022
896a978
[WIP] ASMHELPERS
clamp03 Nov 14, 2022
7c9508c
[WIP] PINVOKESTUBS
clamp03 Nov 14, 2022
f6e85fa
[WIP] RESTORE getcontext.S and setcontext.S in libunwind
clamp03 Nov 14, 2022
4c12c26
[WIP] FIX THREADS.CPP
clamp03 Nov 15, 2022
f5e184d
[WIP] FIX PRECODE
clamp03 Nov 15, 2022
df30a97
[WIP] SET REG
clamp03 Nov 15, 2022
322c2b9
[WIP] FIX INTERPRETER
clamp03 Nov 21, 2022
1120e51
[WIP] Revert Interpreter Code Changes
clamp03 Nov 24, 2022
93d30e7
[WIP] JIT
clamp03 Nov 24, 2022
47938e6
[WIP] JIT
clamp03 Nov 25, 2022
a01b735
[WIP] JIT
clamp03 Nov 30, 2022
7bf58ed
[WIP] JIT
clamp03 Dec 1, 2022
da5220a
[WIP] JIT
clamp03 Dec 2, 2022
c7063e9
[WIP] JIT
clamp03 Dec 5, 2022
55a83da
[WIP] JIT
clamp03 Dec 5, 2022
894ac25
[WIP] JIT
clamp03 Dec 6, 2022
a5d54c3
[WIP] JIT
clamp03 Dec 7, 2022
6377887
[WIP] JIT
clamp03 Dec 9, 2022
95119c7
[WIP] JIT
clamp03 Dec 19, 2022
eb939c1
[WIP] JIT
clamp03 Dec 20, 2022
c241e32
[WIP] JIT
clamp03 Dec 20, 2022
0893b92
[WIP] JIT
clamp03 Dec 20, 2022
a03513a
[WIP] JIT
clamp03 Dec 21, 2022
e714c1a
[WIP] JIT
clamp03 Dec 22, 2022
dfde411
[WIP] JIT
clamp03 Dec 22, 2022
3683323
[WIP] JIT
clamp03 Dec 23, 2022
733a4d5
[WIP] JIT
clamp03 Dec 26, 2022
18c37ce
[WIP] JIT
clamp03 Dec 27, 2022
ade1a59
[WIP] JIT
clamp03 Dec 29, 2022
b3cf2ae
[WIP] JIT
clamp03 Dec 29, 2022
589f6a3
[WIP] JIT
clamp03 Jan 2, 2023
8f91e27
[WIP] JIT
clamp03 Jan 2, 2023
6882d87
[WIP] FIX JIT ERRORS
clamp03 Jan 3, 2023
ca1ad78
[WIP] FIX PROLOG REGISTER SAVES
clamp03 Jan 3, 2023
29699c1
[WIP] FIX and UPDATE JIT
clamp03 Jan 3, 2023
54f892b
[WIP] IMPLEMENTS SHIFT, ROTATE, NEG, NOT and FENCE
clamp03 Jan 3, 2023
558f214
[WIP] JIT UPDATE
clamp03 Jan 4, 2023
bc14f0a
[WIP] FIX DISP
clamp03 Jan 5, 2023
d8fe5ca
[WIP] JIT DEBUGGING
clamp03 Jan 5, 2023
4bc1b27
[WIP] JIT
clamp03 Jan 9, 2023
e1da0a6
[WIP] JIT
clamp03 Jan 10, 2023
b5f8bd5
[WIP] JIT
clamp03 Jan 11, 2023
f23ef1b
[WIP] JIT
clamp03 Jan 11, 2023
3fbfff1
[WIP] FIX JIT
clamp03 Jan 12, 2023
6b64b3d
[WIP] JIT
clamp03 Jan 12, 2023
52aafd2
[WIP] JIT
clamp03 Jan 12, 2023
eea327c
[WIP] JIT
clamp03 Jan 13, 2023
81fe2a0
[WIP] JIT
clamp03 Jan 13, 2023
13650ae
[WIP] JIT
clamp03 Jan 13, 2023
e753f43
[WIP] JIT
clamp03 Jan 16, 2023
d44f9ec
[WIP] JIT
clamp03 Jan 16, 2023
a601385
[WIP] JIT
clamp03 Jan 17, 2023
12ccf4f
[WIP] JIT
clamp03 Jan 17, 2023
8a87d86
[WIP] JIT
clamp03 Jan 18, 2023
c00a4cd
[WIP] JIT
clamp03 Jan 18, 2023
57df5a9
[WIP] JIT
clamp03 Jan 19, 2023
0db2c5c
[WIP] JIT
clamp03 Jan 19, 2023
be097ae
[WIP] JIT
clamp03 Jan 19, 2023
5f2eb7b
[WIP] JIT
clamp03 Jan 20, 2023
e9b852e
[WIP] JIT
clamp03 Jan 20, 2023
4709724
[WIP] JIT
clamp03 Jan 20, 2023
c58aee1
[WIP] JIT
clamp03 Jan 20, 2023
498276f
[WIP] JIT
clamp03 Jan 20, 2023
5cae87a
[WIP] JIT
clamp03 Jan 30, 2023
af66496
[WIP] JIT
clamp03 Jan 31, 2023
a6791ed
[WIP] JIT
clamp03 Feb 1, 2023
15b448e
[WIP] JIT
clamp03 Feb 1, 2023
407e25d
[WIP] JIT
clamp03 Feb 1, 2023
2b3b528
[WIP] JIT
clamp03 Feb 2, 2023
5638069
[WIP] JIT
clamp03 Feb 2, 2023
9641baf
[WIP] JIT
clamp03 Feb 3, 2023
5070785
[WIP] JIT
clamp03 Feb 3, 2023
553c1fd
[WIP] JIT
clamp03 Feb 7, 2023
e7a0474
[WIP] TESTS
clamp03 Feb 13, 2023
e147059
[WIP] JIT
clamp03 Feb 13, 2023
91ce589
[WIP] PALTEST
clamp03 Feb 15, 2023
0827ede
[WIP] FIX AFTER REBASE
clamp03 Feb 17, 2023
6b81f2d
[WIP] Remove commented codes
clamp03 Feb 17, 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
Prev Previous commit
Next Next commit
[WIP] JIT DEBUGGING
  • Loading branch information
clamp03 committed Feb 17, 2023
commit d8fe5ca2413ec41fd0921342317752e64014c575
45 changes: 44 additions & 1 deletion src/coreclr/jit/codegenriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2530,7 +2530,50 @@ void CodeGen::genCodeForJumpTrue(GenTreeOp* jtrue)
//
void CodeGen::genCodeForJumpCompare(GenTreeOp* tree)
{
NYI("unimplemented on RISCV64 yet");
assert(compiler->compCurBB->bbJumpKind == BBJ_COND);

GenTree* op1 = tree->gtGetOp1();
GenTree* op2 = tree->gtGetOp2();

assert(tree->OperIs(GT_JCMP));
assert(!varTypeIsFloating(tree));
assert(!op1->isUsedFromMemory());
assert(!op2->isUsedFromMemory());
assert(op2->IsCnsIntOrI());
assert(op2->isContained());

genConsumeOperands(tree);

regNumber reg = op1->GetRegNum();
emitAttr attr = emitActualTypeSize(op1->TypeGet());

instruction ins;
int regs;
ssize_t imm = op2->AsIntCon()->gtIconVal;
assert(reg != REG_T6); // TODO R21 => T6
assert(reg != REG_RA);

if (attr == EA_4BYTE)
{
imm = (int32_t)imm;
GetEmitter()->emitIns_R_R_I(INS_slliw, EA_4BYTE, REG_RA, reg, 0);
reg = REG_RA;
}

if (imm != 0)
{
GetEmitter()->emitIns_I_la(EA_PTRSIZE, REG_T6, imm);
regs = (int)reg << 5;
regs |= (int)REG_T6;
ins = (tree->gtFlags & GTF_JCMP_EQ) ? INS_beq : INS_bne;
}
else
{
regs = (int)reg;
ins = (tree->gtFlags & GTF_JCMP_EQ) ? INS_beqz : INS_bnez;
}

GetEmitter()->emitIns_J(ins, compiler->compCurBB->bbJumpDest, regs); // 5-bits;
}

//---------------------------------------------------------------------
Expand Down
13 changes: 7 additions & 6 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4327,7 +4327,7 @@ bool Compiler::gtMarkAddrMode(GenTree* addr, int* pCostEx, int* pCostSz, var_typ
{
if (!emitter::isValidSimm12(cns))
{
// TODO-RISCV64: tune for LoongArch64.
// TODO-RISCV64: tune for RISCV64.
addrModeCostEx += 1;
addrModeCostSz += 4;
}
Expand Down Expand Up @@ -4867,6 +4867,7 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)
costEx = 2;
costSz = 8;
#elif defined(TARGET_RISCV64)
// TODO-RISCV64-CQ: tune the costs.
costEx = 2;
costSz = 8;
_ASSERTE(!"TODO RISCV64 NYI");
Expand Down Expand Up @@ -8113,7 +8114,7 @@ bool GenTreeOp::UsesDivideByConstOptimized(Compiler* comp)
}

// TODO-ARM-CQ: Currently there's no GT_MULHI for ARM32
#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
if (!comp->opts.MinOpts() && ((divisorValue >= 3) || !isSignedDivide))
{
// All checks pass we can perform the division operation using a reciprocal multiply.
Expand Down Expand Up @@ -17066,7 +17067,7 @@ const GenTreeLclVarCommon* GenTree::IsLocalAddrExpr() const
//
GenTreeLclVarCommon* GenTree::IsImplicitByrefParameterValuePreMorph(Compiler* compiler)
{
#if FEATURE_IMPLICIT_BYREFS && !defined(TARGET_LOONGARCH64) // TODO-LOONGARCH64-CQ: enable this.
#if FEATURE_IMPLICIT_BYREFS && !defined(TARGET_LOONGARCH64) && !defined(TARGET_RISCV64) // TODO-LOONGARCH64-CQ & TODO-RISCV64: enable this.

GenTreeLclVarCommon* lcl = OperIsLocal() ? AsLclVarCommon() : nullptr;

Expand All @@ -17075,7 +17076,7 @@ GenTreeLclVarCommon* GenTree::IsImplicitByrefParameterValuePreMorph(Compiler* co
return lcl;
}

#endif // FEATURE_IMPLICIT_BYREFS && !defined(TARGET_LOONGARCH64)
#endif // FEATURE_IMPLICIT_BYREFS && !defined(TARGET_LOONGARCH64) && !defined(TARGET_RISCV64)

return nullptr;
}
Expand Down Expand Up @@ -24240,7 +24241,7 @@ void ReturnTypeDesc::InitializeStructReturnType(Compiler* comp,
m_regType[i] = comp->getJitGCType(gcPtrs[i]);
}

#elif defined(TARGET_LOONGARCH64)
#elif defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
assert((structSize >= TARGET_POINTER_SIZE) && (structSize <= (2 * TARGET_POINTER_SIZE)));

uint32_t floatFieldFlags = comp->info.compCompHnd->getLoongArch64PassStructInRegisterFlags(retClsHnd);
Expand Down Expand Up @@ -24500,7 +24501,7 @@ regNumber ReturnTypeDesc::GetABIReturnReg(unsigned idx) const
resultReg = (regNumber)((unsigned)(REG_FLOATRET) + idx); // V0, V1, V2 or V3
}

#elif defined(TARGET_LOONGARCH64)
#elif defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
var_types regType = GetReturnRegType(idx);
if (idx == 0)
{
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -4468,7 +4468,7 @@ struct CallArgABIInformation
, StructIntRegs(0)
, StructFloatRegs(0)
#endif
#ifdef TARGET_LOONGARCH64
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
, StructFloatFieldType()
#endif
, ArgType(TYP_UNDEF)
Expand Down Expand Up @@ -4508,7 +4508,7 @@ struct CallArgABIInformation
unsigned StructFloatRegs;
SYSTEMV_AMD64_CORINFO_STRUCT_REG_PASSING_DESCRIPTOR StructDesc;
#endif // UNIX_AMD64_ABI
#ifdef TARGET_LOONGARCH64
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
// For LoongArch64's ABI, the struct which has float field(s) and no more than two fields
// may be passed by float register(s).
// e.g `struct {int a; float b;}` passed by an integer register and a float register.
Expand Down Expand Up @@ -5291,7 +5291,7 @@ struct GenTreeCall final : public GenTree
bool HasMultiRegRetVal() const
{
#ifdef FEATURE_MULTIREG_RET
#if defined(TARGET_LOONGARCH64)
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
return (gtType == TYP_STRUCT) && (gtReturnTypeDesc.GetReturnRegCount() > 1);
#else

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4600,10 +4600,10 @@ GenTree* Compiler::impFixupStructReturnType(GenTree* op)
// In contrast, we can only use multi-reg calls directly if they have the exact same ABI.
// Calling convention equality is a conservative approximation for that check.
if (op->IsCall() && (op->AsCall()->GetUnmanagedCallConv() == info.compCallConv)
#if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
// TODO-Review: this seems unnecessary. Return ABI doesn't change under varargs.
&& !op->AsCall()->IsVarargs()
#endif // defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64)
#endif // defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
)
{
return op;
Expand Down
24 changes: 12 additions & 12 deletions src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ GenTree* Lowering::LowerNode(GenTree* node)
LowerCast(node);
break;

#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
case GT_BOUNDS_CHECK:
ContainCheckBoundsChk(node->AsBoundsChk());
break;
Expand Down Expand Up @@ -454,7 +454,7 @@ GenTree* Lowering::LowerNode(GenTree* node)
case GT_LSH:
case GT_RSH:
case GT_RSZ:
#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
LowerShift(node->AsOp());
#else
ContainCheckShiftRotate(node->AsOp());
Expand Down Expand Up @@ -527,7 +527,7 @@ GenTree* Lowering::LowerNode(GenTree* node)
LowerStoreLocCommon(node->AsLclVarCommon());
break;

#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
case GT_CMPXCHG:
CheckImmedAndMakeContained(node, node->AsCmpXchg()->gtOpComparand);
break;
Expand Down Expand Up @@ -1511,7 +1511,7 @@ void Lowering::LowerArg(GenTreeCall* call, CallArg* callArg, bool late)
#endif // !defined(TARGET_64BIT)
{

#if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
if (call->IsVarargs() || comp->opts.compUseSoftFP)
{
// For vararg call or on armel, reg args should be all integer.
Expand All @@ -1522,7 +1522,7 @@ void Lowering::LowerArg(GenTreeCall* call, CallArg* callArg, bool late)
type = newNode->TypeGet();
}
}
#endif // TARGET_ARMARCH || TARGET_LOONGARCH64
#endif // TARGET_ARMARCH || TARGET_LOONGARCH64 || TARGET_RISCV64

GenTree* putArg = NewPutArg(call, arg, callArg, type);

Expand All @@ -1543,7 +1543,7 @@ void Lowering::LowerArg(GenTreeCall* call, CallArg* callArg, bool late)
}
}

#if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
//------------------------------------------------------------------------
// LowerFloatArg: Lower float call arguments on the arm/LoongArch64 platform.
//
Expand Down Expand Up @@ -3249,14 +3249,14 @@ GenTree* Lowering::LowerJTrue(GenTreeOp* jtrue)
GenTree* relopOp1 = relop->gtGetOp1();
GenTree* relopOp2 = relop->gtGetOp2();

#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)

if ((relop->gtNext == jtrue) && relopOp2->IsCnsIntOrI())
{
bool useJCMP = false;
GenTreeFlags flags = GTF_EMPTY;

#if defined(TARGET_LOONGARCH64)
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
if (relop->OperIs(GT_EQ, GT_NE))
{
// Codegen will use beq or bne.
Expand Down Expand Up @@ -3293,7 +3293,7 @@ GenTree* Lowering::LowerJTrue(GenTreeOp* jtrue)
return nullptr;
}
}
#endif // TARGET_ARM64 || TARGET_LOONGARCH64
#endif // TARGET_ARM64 || TARGET_LOONGARCH64 || TARGET_RISCV64

assert(relop->OperIsCompare());
assert(relop->gtNext == jtrue);
Expand Down Expand Up @@ -4123,7 +4123,7 @@ void Lowering::LowerStoreSingleRegCallStruct(GenTreeBlk* store)

if (regType != TYP_UNDEF)
{
#if defined(TARGET_LOONGARCH64)
#if defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
if (varTypeIsFloating(call->TypeGet()))
{
regType = call->TypeGet();
Expand Down Expand Up @@ -5827,7 +5827,7 @@ bool Lowering::LowerUnsignedDivOrMod(GenTreeOp* divMod)
}

// TODO-ARM-CQ: Currently there's no GT_MULHI for ARM32
#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
if (!comp->opts.MinOpts() && (divisorValue >= 3))
{
size_t magic;
Expand Down Expand Up @@ -6115,7 +6115,7 @@ GenTree* Lowering::LowerConstIntDivOrMod(GenTree* node)
return nullptr;
}

#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_XARCH) || defined(TARGET_ARM64) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
ssize_t magic;
int shift;

Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lower.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class Lowering final : public Phase
void ReplaceArgWithPutArgOrBitcast(GenTree** ppChild, GenTree* newNode);
GenTree* NewPutArg(GenTreeCall* call, GenTree* arg, CallArg* callArg, var_types type);
void LowerArg(GenTreeCall* call, CallArg* callArg, bool late);
#if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64)
#if defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined(TARGET_RISCV64)
GenTree* LowerFloatArg(GenTree** pArg, CallArg* callArg);
GenTree* LowerFloatArgReg(GenTree* arg, regNumber regNum);
#endif
Expand Down
Loading