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

JIT: Rewrite initial parameter frame layout in terms of new ABI info #101340

Merged
merged 12 commits into from
May 8, 2024
17 changes: 9 additions & 8 deletions src/coreclr/jit/abi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ regMaskTP ABIPassingSegment::GetRegisterMask() const
// Offset relative to the first stack argument.
//
// Remarks:
// On x86, where arguments are pushed in order and thus come in reverse order
// in the callee, this is the offset to subtract from the top of the stack to
// get the argument's address. By top of the stack is meant esp on entry + 4
// for the return address + total size of stack arguments. In varargs methods
// the varargs cookie contains the information required to allow the
// computation of the total size of stack arguments.
//
// Outside x86 this is the offset to add to the first argument's address.
// On x86, for the managed ABI where arguments are pushed in order and thus
// come in reverse order in the callee, this is the offset to subtract from
// the top of the stack to get the argument's address. By top of the stack is
// meant esp on entry + 4 for the return address + total size of stack
// arguments. In varargs methods the varargs cookie contains the information
// required to allow the computation of the total size of stack arguments.
//
// Outside the managed x86 ABI this is the offset to add to the first
// argument's address.
//
unsigned ABIPassingSegment::GetStackOffset() const
{
Expand Down
47 changes: 44 additions & 3 deletions src/coreclr/jit/abi.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,18 @@ struct ClassifierInfo

class X86Classifier
{
RegisterQueue m_regs;
unsigned m_stackArgSize = 0;
const ClassifierInfo& m_info;
RegisterQueue m_regs;
unsigned m_stackArgSize = 0;

public:
X86Classifier(const ClassifierInfo& info);

unsigned StackSize()
{
return m_stackArgSize;
}

ABIPassingInformation Classify(Compiler* comp,
var_types type,
ClassLayout* structLayout,
Expand All @@ -122,11 +128,16 @@ class WinX64Classifier
{
RegisterQueue m_intRegs;
RegisterQueue m_floatRegs;
unsigned m_stackArgSize = 0;
unsigned m_stackArgSize = 32;

public:
WinX64Classifier(const ClassifierInfo& info);

unsigned StackSize()
{
return m_stackArgSize;
}

ABIPassingInformation Classify(Compiler* comp,
var_types type,
ClassLayout* structLayout,
Expand All @@ -142,6 +153,11 @@ class SysVX64Classifier
public:
SysVX64Classifier(const ClassifierInfo& info);

unsigned StackSize()
{
return m_stackArgSize;
}

ABIPassingInformation Classify(Compiler* comp,
var_types type,
ClassLayout* structLayout,
Expand All @@ -158,6 +174,11 @@ class Arm64Classifier
public:
Arm64Classifier(const ClassifierInfo& info);

unsigned StackSize()
{
return roundUp(m_stackArgSize, TARGET_POINTER_SIZE);
}

ABIPassingInformation Classify(Compiler* comp,
var_types type,
ClassLayout* structLayout,
Expand All @@ -182,6 +203,11 @@ class Arm32Classifier
public:
Arm32Classifier(const ClassifierInfo& info);

unsigned StackSize()
{
return m_stackArgSize;
}

ABIPassingInformation Classify(Compiler* comp,
var_types type,
ClassLayout* structLayout,
Expand All @@ -198,6 +224,11 @@ class RiscV64Classifier
public:
RiscV64Classifier(const ClassifierInfo& info);

unsigned StackSize()
{
return m_stackArgSize;
}

ABIPassingInformation Classify(Compiler* comp,
var_types type,
ClassLayout* structLayout,
Expand All @@ -214,6 +245,11 @@ class LoongArch64Classifier
public:
LoongArch64Classifier(const ClassifierInfo& info);

unsigned StackSize()
{
return m_stackArgSize;
}

ABIPassingInformation Classify(Compiler* comp,
var_types type,
ClassLayout* structLayout,
Expand Down Expand Up @@ -247,6 +283,11 @@ class SwiftABIClassifier
{
}

unsigned StackSize()
{
return m_classifier.StackSize();
}

ABIPassingInformation Classify(Compiler* comp,
var_types type,
ClassLayout* structLayout,
Expand Down
7 changes: 2 additions & 5 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3784,6 +3784,7 @@ class Compiler
unsigned lvaTableCnt; // lvaTable size (>= lvaCount)

ABIPassingInformation* lvaParameterPassingInfo;
unsigned lvaParameterStackSize;

unsigned lvaTrackedCount; // actual # of locals being tracked
unsigned lvaTrackedCountInSizeTUnits; // min # of size_t's sufficient to hold a bit for all the locals being tracked
Expand Down Expand Up @@ -3931,11 +3932,7 @@ class Compiler
void lvaUpdateArgWithInitialReg(LclVarDsc* varDsc);
void lvaUpdateArgsWithInitialReg();
void lvaAssignVirtualFrameOffsetsToArgs();
#ifdef UNIX_AMD64_ABI
int lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, unsigned argSize, int argOffs, int* callerArgOffset);
#else // !UNIX_AMD64_ABI
int lvaAssignVirtualFrameOffsetToArg(unsigned lclNum, unsigned argSize, int argOffs);
#endif // !UNIX_AMD64_ABI
bool lvaGetRelativeOffsetToCallerAllocatedSpaceForParameter(unsigned lclNum, int* offset);
void lvaAssignVirtualFrameOffsetsToLocals();
bool lvaParamHasLocalStackSpace(unsigned lclNum);
int lvaAllocLocalAndSetVirtualOffset(unsigned lclNum, unsigned size, int stkOffs);
Expand Down
Loading
Loading