Skip to content
Closed
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
2 changes: 0 additions & 2 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3998,9 +3998,7 @@ class Compiler
void gtDispLeaf(GenTree* tree, IndentStack* indentStack);
void gtDispLocal(GenTreeLclVarCommon* tree, IndentStack* indentStack);
void gtDispNodeName(GenTree* tree);
#if FEATURE_MULTIREG_RET
unsigned gtDispMultiRegCount(GenTree* tree);
#endif
void gtDispRegVal(GenTree* tree);
void gtDispVN(GenTree* tree);
void gtDispCommonEndLine(GenTree* tree);
Expand Down
81 changes: 29 additions & 52 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,29 +737,6 @@ ClassLayout* GenTree::GetLayout(Compiler* compiler) const
return compiler->typGetObjLayout(structHnd);
}

//-----------------------------------------------------------
// CopyReg: Copy the _gtRegNum/gtRegTag fields.
//
// Arguments:
// from - GenTree node from which to copy
//
void GenTree::CopyReg(GenTree* from)
{
_gtRegNum = from->_gtRegNum;
INDEBUG(gtRegTag = from->gtRegTag;)

// Also copy multi-reg state if this is a call node
if (IsCall())
{
assert(from->IsCall());
this->AsCall()->CopyOtherRegs(from->AsCall());
}
else if (IsCopyOrReload())
{
this->AsCopyOrReload()->CopyOtherRegs(from->AsCopyOrReload());
}
}

//------------------------------------------------------------------
// gtHasReg: Whether node been assigned a register by LSRA
//
Expand Down Expand Up @@ -857,44 +834,46 @@ bool GenTree::gtHasReg(Compiler* comp) const
int GenTree::GetRegisterDstCount(Compiler* compiler) const
{
assert(!isContained());
if (!IsMultiRegNode())
{
return IsValue() ? 1 : 0;
}
else if (IsMultiRegCall())

#if FEATURE_MULTIREG_RET
if (IsMultiRegCall())
{
return AsCall()->GetReturnTypeDesc()->GetReturnRegCount();
}
else if (IsCopyOrReload())
{
return gtGetOp1()->GetRegisterDstCount(compiler);
}

#if !defined(TARGET_64BIT)
else if (OperIsMultiRegOp())
if (OperIsMultiRegOp())
{
assert(OperIs(GT_MUL_LONG));
return 2;
}
#endif
#ifdef FEATURE_HW_INTRINSICS
else if (OperIsHWIntrinsic())
#endif // FEATURE_MULTIREG_RET

if (IsCopyOrReload())
{
assert(TypeIs(TYP_STRUCT));
return gtGetOp1()->GetRegisterDstCount(compiler);
}

const GenTreeHWIntrinsic* intrinsic = AsHWIntrinsic();
const NamedIntrinsic intrinsicId = intrinsic->GetHWIntrinsicId();
assert(HWIntrinsicInfo::IsMultiReg(intrinsicId));
#ifdef FEATURE_HW_INTRINSICS
if (OperIsHWIntrinsic())
{
const NamedIntrinsic intrinsicId = AsHWIntrinsic()->GetHWIntrinsicId();

return HWIntrinsicInfo::GetMultiRegCount(intrinsicId);
if (HWIntrinsicInfo::IsMultiReg(intrinsicId))
{
return HWIntrinsicInfo::GetMultiRegCount(intrinsicId);
}
}
#endif // FEATURE_HW_INTRINSICS

if (OperIsScalarLocal())
if (IsMultiRegLclVar())
{
return AsLclVar()->GetFieldCount(compiler);
}
assert(!"Unexpected multi-reg node");
return 0;

assert(!IsMultiRegNode());
return IsValue() ? 1 : 0;
}

//-----------------------------------------------------------------------------------
Expand Down Expand Up @@ -927,7 +906,7 @@ bool GenTree::IsMultiRegNode() const
#endif
#endif // FEATURE_MULTIREG_RET

if (OperIs(GT_COPY, GT_RELOAD))
if (IsCopyOrReload())
{
return true;
}
Expand Down Expand Up @@ -11281,7 +11260,10 @@ GenTree* Compiler::gtCloneExpr(GenTree* tree)
/* Make sure to copy back fields that may have been initialized */

copy->CopyRawCosts(tree);
copy->CopyReg(tree);

assert(tree->GetRegNum() == REG_NA);
assert(tree->GetRegTag() == GenTree::GT_REGTAG_NONE);

Comment on lines 11262 to +11266
return copy;
}

Expand Down Expand Up @@ -11430,8 +11412,6 @@ GenTreeCall* Compiler::gtCloneExprCallHelper(GenTreeCall* tree)

copy->gtInlineContext = tree->gtInlineContext;

copy->CopyOtherRegFlags(tree);

// We keep track of the number of no return calls, so if we've cloned
// one of these, update the tracking.
//
Expand Down Expand Up @@ -11473,7 +11453,8 @@ GenTreeCall* Compiler::gtCloneCandidateCall(GenTreeCall* call)
result->gtDebugFlags |= (call->gtDebugFlags & ~GTF_DEBUG_NODE_MASK);
#endif

result->CopyReg(call);
assert(call->GetRegNum() == REG_NA);
assert(call->GetRegTag() == GenTree::GT_REGTAG_NONE);

return result;
}
Expand Down Expand Up @@ -13021,7 +13002,6 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, _In_ _In_opt_
}
}

#if FEATURE_MULTIREG_RET
//----------------------------------------------------------------------------------
// gtDispMultiRegCount: determine how many registers to print for a multi-reg node
//
Expand Down Expand Up @@ -13067,7 +13047,6 @@ unsigned Compiler::gtDispMultiRegCount(GenTree* tree)
return tree->GetMultiRegCount(this);
}
}
#endif // FEATURE_MULTIREG_RET

//----------------------------------------------------------------------------------
// gtDispRegVal: Print the register(s) defined by the given node
Expand All @@ -13090,7 +13069,6 @@ void Compiler::gtDispRegVal(GenTree* tree)
return;
}

#if FEATURE_MULTIREG_RET
if (tree->IsMultiRegNode())
{
// 0th reg is GetRegNum(), which is already printed above.
Expand All @@ -13104,7 +13082,6 @@ void Compiler::gtDispRegVal(GenTree* tree)
printf(",%s", genIsValidReg(reg) ? compRegVarName(reg) : "NA");
}
}
#endif
}

// We usually/commonly don't expect to print anything longer than this string,
Expand Down
61 changes: 2 additions & 59 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1097,8 +1097,6 @@ struct GenTree
INDEBUG(gtRegTag = GT_REGTAG_NONE;)
}

// Copy the _gtRegNum/gtRegTag fields
void CopyReg(GenTree* from);
bool gtHasReg(Compiler* comp) const;

int GetRegisterDstCount(Compiler* compiler) const;
Expand Down Expand Up @@ -4003,21 +4001,6 @@ struct GenTreeLclVar : public GenTreeLclVarCommon
gtSpillFlags = 0;
}

//-------------------------------------------------------------------------
// CopyOtherRegFlags: copy GTF_* flags associated with gtOtherRegs from
// the given LclVar node.
//
// Arguments:
// fromCall - GenTreeLclVar node from which to copy
//
// Return Value:
// None
//
void CopyOtherRegFlags(GenTreeLclVar* from)
{
this->gtSpillFlags = from->gtSpillFlags;
}

#ifdef DEBUG
void ResetLclILoffs()
{
Expand Down Expand Up @@ -5330,8 +5313,9 @@ struct GenTreeCall final : public GenTree
#if FEATURE_MULTIREG_RET
for (unsigned i = 0; i < MAX_RET_REG_COUNT - 1; ++i)
{
this->gtOtherRegs[i] = fromCall->gtOtherRegs[i];
gtOtherRegs[i] = fromCall->gtOtherRegs[i];
}
gtSpillFlags = fromCall->gtSpillFlags;
#endif
}

Expand Down Expand Up @@ -5374,23 +5358,6 @@ struct GenTreeCall final : public GenTree
#endif
}

//-------------------------------------------------------------------------
// CopyOtherRegFlags: copy GTF_* flags associated with gtOtherRegs from
// the given call node.
//
// Arguments:
// fromCall - GenTreeCall node from which to copy
//
// Return Value:
// None
//
void CopyOtherRegFlags(GenTreeCall* fromCall)
{
#if FEATURE_MULTIREG_RET
this->gtSpillFlags = fromCall->gtSpillFlags;
#endif
}

bool IsUnmanaged() const
{
return (gtFlags & GTF_CALL_UNMANAGED) != 0;
Expand Down Expand Up @@ -8971,30 +8938,6 @@ struct GenTreeCopyOrReload : public GenTreeUnOp
}
}

//----------------------------------------------------------------------------
// CopyOtherRegs: copy multi-reg state from the given copy/reload node to this
// node.
//
// Arguments:
// from - GenTree node from which to copy multi-reg state
//
// Return Value:
// None
//
// TODO-ARM: Implement this routine for Arm64 and Arm32
// TODO-X86: Implement this routine for x86
void CopyOtherRegs(GenTreeCopyOrReload* from)
{
assert(OperGet() == from->OperGet());

#ifdef UNIX_AMD64_ABI
for (unsigned i = 0; i < MAX_MULTIREG_COUNT - 1; ++i)
{
gtOtherRegs[i] = from->gtOtherRegs[i];
}
#endif
}

unsigned GetRegCount() const
{
// We need to return the highest index for which we have a valid register.
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/optcse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5234,8 +5234,8 @@ void CSE_HeuristicCommon::PerformCSE(CSE_Candidate* successfulCandidate)
//
void CSE_HeuristicCommon::ReplaceCSENode(Statement* stmt, GenTree* exp, GenTree* newNode)
{
newNode->CopyReg(exp); // The cse inheirits any reg num property from the original exp node
exp->ClearRegNum(); // The exp node (for a CSE def) no longer has a register requirement
assert(exp->GetRegNum() == REG_NA);
assert(exp->GetRegTag() == GenTree::GT_REGTAG_NONE);

Comment on lines +5237 to 5239
// Walk the statement 'stmt' and find the pointer
// in the tree is pointing to 'exp'
Expand Down
Loading