Skip to content

Commit

Permalink
Code review from dotnet#101114
Browse files Browse the repository at this point in the history
  • Loading branch information
tomeksowi committed Apr 19, 2024
1 parent 3cea1ee commit 25ab569
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/jit/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ struct ABIPassingInformation
// - On loongarch64/riscv64, structs can be passed in two registers or
// can be split out over register and stack, giving
// multiple register segments and a struct segment.
unsigned NumSegments = 0;
ABIPassingSegment* Segments = nullptr;
unsigned NumSegments;
ABIPassingSegment* Segments;

ABIPassingInformation(unsigned numSegments = 0, ABIPassingSegment* segments = nullptr)
: NumSegments(numSegments)
Expand Down
24 changes: 9 additions & 15 deletions src/coreclr/jit/targetriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ RiscV64Classifier::RiscV64Classifier(const ClassifierInfo& info)
, m_intRegs(intArgRegs, ArrLen(intArgRegs))
, m_floatRegs(fltArgRegs, ArrLen(fltArgRegs))
{
assert(!m_info.IsVarArgs); // TODO: varargs currently not supported on RISC-V
}

//-----------------------------------------------------------------------------
Expand All @@ -57,8 +58,6 @@ ABIPassingInformation RiscV64Classifier::Classify(Compiler* comp,
ClassLayout* structLayout,
WellKnownArg /*wellKnownParam*/)
{
assert(!m_info.IsVarArgs); // TODO: varargs currently not supported on RISC-V

StructFloatFieldInfoFlags flags = STRUCT_NO_FLOAT_FIELD;
unsigned intFields = 0, floatFields = 0;
unsigned passedSize;
Expand Down Expand Up @@ -93,17 +92,14 @@ ABIPassingInformation RiscV64Classifier::Classify(Compiler* comp,
}
else
{
assert(genTypeSize(type) <= TARGET_POINTER_SIZE);

if (varTypeIsFloating(type))
floatFields = 1;

passedSize = genTypeSize(type);
assert(passedSize <= TARGET_POINTER_SIZE);
floatFields = varTypeIsFloating(type) ? 1 : 0;
}

assert((floatFields > 0) || (intFields == 0));

auto PassSlot = [this](bool inFloatReg, unsigned offset, unsigned size) -> ABIPassingSegment {
auto passSlot = [this](bool inFloatReg, unsigned offset, unsigned size) -> ABIPassingSegment {
assert(size > 0);
assert(size <= TARGET_POINTER_SIZE);
if (inFloatReg)
Expand Down Expand Up @@ -151,27 +147,25 @@ ABIPassingInformation RiscV64Classifier::Classify(Compiler* comp,
bool isSecondFloat = (flags & (STRUCT_FLOAT_FIELD_ONLY_TWO | STRUCT_FLOAT_FIELD_SECOND)) != 0;
assert(isFirstFloat || isSecondFloat);

return {2, new (comp, CMK_ABI) ABIPassingSegment[]{PassSlot(isFirstFloat, 0, firstSize),
PassSlot(isSecondFloat, offset, secondSize)}};
return {2, new (comp, CMK_ABI) ABIPassingSegment[]{passSlot(isFirstFloat, 0, firstSize),
passSlot(isSecondFloat, offset, secondSize)}};
}
}
else
{
// Integer calling convention
if (passedSize <= TARGET_POINTER_SIZE)
{
return ABIPassingInformation::FromSegment(comp, PassSlot(false, 0, passedSize));
return ABIPassingInformation::FromSegment(comp, passSlot(false, 0, passedSize));
}
else
{
assert(varTypeIsStruct(type));
return {2, new (comp, CMK_ABI)
ABIPassingSegment[]{PassSlot(false, 0, TARGET_POINTER_SIZE),
PassSlot(false, TARGET_POINTER_SIZE, passedSize - TARGET_POINTER_SIZE)}};
ABIPassingSegment[]{passSlot(false, 0, TARGET_POINTER_SIZE),
passSlot(false, TARGET_POINTER_SIZE, passedSize - TARGET_POINTER_SIZE)}};
}
}

unreached();
}

#endif // TARGET_RISCV64

0 comments on commit 25ab569

Please sign in to comment.