Skip to content

Commit

Permalink
Delete GT_STORE_OBJ (#84951)
Browse files Browse the repository at this point in the history
* Rationalization

* General lowering

* General LSRA

* XARCH backend

* ARMARCH backend

* LA64 backend

* RISCV64 backend

* General IR support
  • Loading branch information
SingleAccretion authored Apr 19, 2023
1 parent 2cfef64 commit 7b662a7
Show file tree
Hide file tree
Showing 23 changed files with 425 additions and 557 deletions.
19 changes: 7 additions & 12 deletions src/coreclr/jit/codegenarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode)
#endif
break;

case GT_STORE_OBJ:
case GT_STORE_DYN_BLK:
case GT_STORE_BLK:
genCodeForStoreBlk(treeNode->AsBlk());
Expand Down Expand Up @@ -4462,28 +4461,24 @@ void CodeGen::inst_JMP(emitJumpKind jmp, BasicBlock* tgtBlock)
}

//------------------------------------------------------------------------
// genCodeForStoreBlk: Produce code for a GT_STORE_OBJ/GT_STORE_DYN_BLK/GT_STORE_BLK node.
// genCodeForStoreBlk: Produce code for a GT_STORE_DYN_BLK/GT_STORE_BLK node.
//
// Arguments:
// tree - the node
//
void CodeGen::genCodeForStoreBlk(GenTreeBlk* blkOp)
{
assert(blkOp->OperIs(GT_STORE_OBJ, GT_STORE_DYN_BLK, GT_STORE_BLK));

if (blkOp->OperIs(GT_STORE_OBJ))
{
assert(!blkOp->gtBlkOpGcUnsafe);
assert(blkOp->OperIsCopyBlkOp());
assert(blkOp->AsBlk()->GetLayout()->HasGCPtr());
genCodeForCpObj(blkOp->AsBlk());
return;
}
assert(blkOp->OperIs(GT_STORE_DYN_BLK, GT_STORE_BLK));

bool isCopyBlk = blkOp->OperIsCopyBlkOp();

switch (blkOp->gtBlkOpKind)
{
case GenTreeBlk::BlkOpKindCpObjUnroll:
assert(!blkOp->gtBlkOpGcUnsafe);
genCodeForCpObj(blkOp->AsBlk());
break;

case GenTreeBlk::BlkOpKindHelper:
assert(!blkOp->gtBlkOpGcUnsafe);
if (isCopyBlk)
Expand Down
19 changes: 8 additions & 11 deletions src/coreclr/jit/codegenloongarch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5206,7 +5206,6 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode)
emit->emitIns_R_L(INS_ld_d, EA_PTRSIZE, genPendingCallLabel, targetReg);
break;

case GT_STORE_OBJ:
case GT_STORE_DYN_BLK:
case GT_STORE_BLK:
genCodeForStoreBlk(treeNode->AsBlk());
Expand Down Expand Up @@ -7544,31 +7543,29 @@ void CodeGen::genCreateAndStoreGCInfo(unsigned codeSize,
}

//------------------------------------------------------------------------
// genCodeForStoreBlk: Produce code for a GT_STORE_OBJ/GT_STORE_DYN_BLK/GT_STORE_BLK node.
// genCodeForStoreBlk: Produce code for a GT_STORE_DYN_BLK/GT_STORE_BLK node.
//
// Arguments:
// tree - the node
//
void CodeGen::genCodeForStoreBlk(GenTreeBlk* blkOp)
{
assert(blkOp->OperIs(GT_STORE_OBJ, GT_STORE_DYN_BLK, GT_STORE_BLK));
assert(blkOp->OperIs(GT_STORE_DYN_BLK, GT_STORE_BLK));

if (blkOp->OperIs(GT_STORE_OBJ))
{
assert(!blkOp->gtBlkOpGcUnsafe);
assert(blkOp->OperIsCopyBlkOp());
assert(blkOp->AsBlk()->GetLayout()->HasGCPtr());
genCodeForCpObj(blkOp->AsBlk());
return;
}
if (blkOp->gtBlkOpGcUnsafe)
{
GetEmitter()->emitDisableGC();
}

bool isCopyBlk = blkOp->OperIsCopyBlkOp();

switch (blkOp->gtBlkOpKind)
{
case GenTreeBlk::BlkOpKindCpObjUnroll:
assert(!blkOp->gtBlkOpGcUnsafe);
genCodeForCpObj(blkOp->AsBlk());
break;

case GenTreeBlk::BlkOpKindHelper:
if (isCopyBlk)
{
Expand Down
18 changes: 7 additions & 11 deletions src/coreclr/jit/codegenriscv64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4537,7 +4537,6 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode)
emit->emitIns_R_L(INS_ld, EA_PTRSIZE, genPendingCallLabel, targetReg);
break;

case GT_STORE_OBJ:
case GT_STORE_DYN_BLK:
case GT_STORE_BLK:
genCodeForStoreBlk(treeNode->AsBlk());
Expand Down Expand Up @@ -6394,23 +6393,15 @@ void CodeGen::genCreateAndStoreGCInfo(unsigned codeSize,
}

//------------------------------------------------------------------------
// genCodeForStoreBlk: Produce code for a GT_STORE_OBJ/GT_STORE_DYN_BLK/GT_STORE_BLK node.
// genCodeForStoreBlk: Produce code for a GT_STORE_DYN_BLK/GT_STORE_BLK node.
//
// Arguments:
// tree - the node
//
void CodeGen::genCodeForStoreBlk(GenTreeBlk* blkOp)
{
assert(blkOp->OperIs(GT_STORE_OBJ, GT_STORE_DYN_BLK, GT_STORE_BLK));
assert(blkOp->OperIs(GT_STORE_DYN_BLK, GT_STORE_BLK));

if (blkOp->OperIs(GT_STORE_OBJ))
{
assert(!blkOp->gtBlkOpGcUnsafe);
assert(blkOp->OperIsCopyBlkOp());
assert(blkOp->AsBlk()->GetLayout()->HasGCPtr());
genCodeForCpObj(blkOp->AsBlk());
return;
}
if (blkOp->gtBlkOpGcUnsafe)
{
GetEmitter()->emitDisableGC();
Expand All @@ -6419,6 +6410,11 @@ void CodeGen::genCodeForStoreBlk(GenTreeBlk* blkOp)

switch (blkOp->gtBlkOpKind)
{
case GenTreeBlk::BlkOpKindCpObjUnroll:
assert(!blkOp->gtBlkOpGcUnsafe);
genCodeForCpObj(blkOp->AsBlk());
break;

case GenTreeBlk::BlkOpKindHelper:
if (isCopyBlk)
{
Expand Down
24 changes: 10 additions & 14 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,6 @@ void CodeGen::genCodeForTreeNode(GenTree* treeNode)
emit->emitIns_R_L(INS_lea, EA_PTR_DSP_RELOC, genPendingCallLabel, treeNode->GetRegNum());
break;

case GT_STORE_OBJ:
case GT_STORE_DYN_BLK:
case GT_STORE_BLK:
genCodeForStoreBlk(treeNode->AsBlk());
Expand Down Expand Up @@ -2983,23 +2982,20 @@ void CodeGen::genLclHeap(GenTree* tree)

void CodeGen::genCodeForStoreBlk(GenTreeBlk* storeBlkNode)
{
assert(storeBlkNode->OperIs(GT_STORE_OBJ, GT_STORE_DYN_BLK, GT_STORE_BLK));

if (storeBlkNode->OperIs(GT_STORE_OBJ))
{
#ifndef JIT32_GCENCODER
assert(!storeBlkNode->gtBlkOpGcUnsafe);
#endif
assert(storeBlkNode->OperIsCopyBlkOp());
assert(storeBlkNode->AsBlk()->GetLayout()->HasGCPtr());
genCodeForCpObj(storeBlkNode->AsBlk());
return;
}
assert(storeBlkNode->OperIs(GT_STORE_DYN_BLK, GT_STORE_BLK));

bool isCopyBlk = storeBlkNode->OperIsCopyBlkOp();

switch (storeBlkNode->gtBlkOpKind)
{
case GenTreeBlk::BlkOpKindCpObjRepInstr:
case GenTreeBlk::BlkOpKindCpObjUnroll:
#ifndef JIT32_GCENCODER
assert(!storeBlkNode->gtBlkOpGcUnsafe);
#endif
genCodeForCpObj(storeBlkNode->AsBlk());
break;

#ifdef TARGET_AMD64
case GenTreeBlk::BlkOpKindHelper:
assert(!storeBlkNode->gtBlkOpGcUnsafe);
Expand Down Expand Up @@ -4087,7 +4083,7 @@ void CodeGen::genClearStackVec3ArgUpperBits()
// GC pointers.
//
// Arguments:
// cpObjNode - the GT_STORE_OBJ
// cpObjNode - the GT_STORE_BLK node
//
// Notes:
// This will generate a sequence of movsp instructions for the cases of non-gc members.
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9938,13 +9938,6 @@ void cTreeFlags(Compiler* comp, GenTree* tree)
}
break;

case GT_STORE_OBJ:
if (tree->AsBlk()->GetLayout()->HasGCPtr())
{
chars += printf("[BLK_HASGCPTR]");
}
FALLTHROUGH;

case GT_BLK:
case GT_STORE_BLK:
case GT_STORE_DYN_BLK:
Expand Down
6 changes: 1 addition & 5 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3264,7 +3264,6 @@ unsigned Compiler::gtHashValue(GenTree* tree)
break;

case GT_STORE_BLK:
case GT_STORE_OBJ:
hash ^= PtrToUlong(tree->AsBlk()->GetLayout());
break;

Expand Down Expand Up @@ -6673,7 +6672,6 @@ bool GenTree::OperIsImplicitIndir() const
case GT_CMPXCHG:
case GT_BLK:
case GT_STORE_BLK:
case GT_STORE_OBJ:
case GT_STORE_DYN_BLK:
case GT_BOX:
case GT_ARR_INDEX:
Expand Down Expand Up @@ -6973,7 +6971,6 @@ GenTree::VtablePtr GenTree::GetVtableForOper(genTreeOps oper)

// Handle the special cases.
// The following opers are in GTSTRUCT_N but no other place (namely, no subtypes).
case GT_STORE_OBJ:
case GT_STORE_BLK:
case GT_BLK:
{
Expand Down Expand Up @@ -10503,7 +10500,6 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, _In_ _In_opt_
case GT_LEA:
case GT_BLK:
case GT_STORE_BLK:
case GT_STORE_OBJ:
case GT_STORE_DYN_BLK:

case GT_IND:
Expand Down Expand Up @@ -10815,7 +10811,7 @@ void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, _In_ _In_opt_
{
ClassLayout* layout = nullptr;

if (tree->OperIs(GT_BLK, GT_STORE_BLK, GT_STORE_OBJ))
if (tree->OperIs(GT_BLK, GT_STORE_BLK))
{
layout = tree->AsBlk()->GetLayout();
}
Expand Down
9 changes: 6 additions & 3 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1225,7 +1225,7 @@ struct GenTree

static bool OperIsStoreBlk(genTreeOps gtOper)
{
return StaticOperIs(gtOper, GT_STORE_BLK, GT_STORE_OBJ, GT_STORE_DYN_BLK);
return StaticOperIs(gtOper, GT_STORE_BLK, GT_STORE_DYN_BLK);
}

bool OperIsStoreBlk() const
Expand Down Expand Up @@ -1547,8 +1547,7 @@ struct GenTree
// OperIsIndir() returns true also for indirection nodes such as GT_BLK, etc. as well as GT_NULLCHECK.
static bool OperIsIndir(genTreeOps gtOper)
{
static_assert_no_msg(
AreContiguous(GT_IND, GT_STOREIND, GT_STORE_OBJ, GT_BLK, GT_STORE_BLK, GT_STORE_DYN_BLK, GT_NULLCHECK));
static_assert_no_msg(AreContiguous(GT_IND, GT_STOREIND, GT_BLK, GT_STORE_BLK, GT_STORE_DYN_BLK, GT_NULLCHECK));
return (GT_IND <= gtOper) && (gtOper <= GT_NULLCHECK);
}

Expand Down Expand Up @@ -7303,6 +7302,10 @@ struct GenTreeBlk : public GenTreeIndir
enum
{
BlkOpKindInvalid,
BlkOpKindCpObjUnroll,
#ifdef TARGET_XARCH
BlkOpKindCpObjRepInstr,
#endif
#ifndef TARGET_X86
BlkOpKindHelper,
#endif
Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/jit/gtlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@ GTNODE(BOUNDS_CHECK , GenTreeBoundsChk ,0,GTK_BINOP|GTK_EXOP|GTK_NOVALUE)

GTNODE(IND , GenTreeIndir ,0,GTK_UNOP) // Load indirection
GTNODE(STOREIND , GenTreeStoreInd ,0,GTK_BINOP|GTK_NOVALUE) // Store indirection
GTNODE(STORE_OBJ , GenTreeBlk ,0,GTK_BINOP|GTK_EXOP|GTK_NOVALUE) // Store for struct objects with GC pointers
GTNODE(BLK , GenTreeBlk ,0,GTK_UNOP|GTK_EXOP) // Block/struct object
GTNODE(STORE_BLK , GenTreeBlk ,0,GTK_BINOP|GTK_EXOP|GTK_NOVALUE) // Block/struct object store
GTNODE(BLK , GenTreeBlk ,0,GTK_UNOP|GTK_EXOP) // Struct load
GTNODE(STORE_BLK , GenTreeBlk ,0,GTK_BINOP|GTK_EXOP|GTK_NOVALUE) // Struct store
GTNODE(STORE_DYN_BLK , GenTreeStoreDynBlk ,0,GTK_SPECIAL|GTK_NOVALUE) // Dynamically sized block store, with native uint size
GTNODE(NULLCHECK , GenTreeIndir ,0,GTK_UNOP|GTK_NOVALUE) // Null checks the source

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/jit/gtstructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ GTSTRUCT_2(CopyOrReload, GT_COPY, GT_RELOAD)
GTSTRUCT_1(ClsVar , GT_CLS_VAR_ADDR)
GTSTRUCT_1(CmpXchg , GT_CMPXCHG)
GTSTRUCT_1(AddrMode , GT_LEA)
GTSTRUCT_N(Blk , GT_BLK, GT_STORE_BLK, GT_STORE_OBJ, GT_STORE_DYN_BLK)
GTSTRUCT_N(Blk , GT_BLK, GT_STORE_BLK, GT_STORE_DYN_BLK)
GTSTRUCT_1(StoreDynBlk , GT_STORE_DYN_BLK)
GTSTRUCT_1(Qmark , GT_QMARK)
GTSTRUCT_1(PhiArg , GT_PHI_ARG)
GTSTRUCT_1(Phi , GT_PHI)
GTSTRUCT_1(StoreInd , GT_STOREIND)
GTSTRUCT_N(Indir , GT_STOREIND, GT_IND, GT_NULLCHECK, GT_BLK, GT_STORE_BLK, GT_STORE_OBJ, GT_STORE_DYN_BLK)
GTSTRUCT_N(Indir , GT_STOREIND, GT_IND, GT_NULLCHECK, GT_BLK, GT_STORE_BLK, GT_STORE_DYN_BLK)
GTSTRUCT_N(Conditional , GT_SELECT)
#if FEATURE_ARG_SPLIT
GTSTRUCT_2_SPECIAL(PutArgStk, GT_PUTARG_STK, GT_PUTARG_SPLIT)
Expand Down
5 changes: 1 addition & 4 deletions src/coreclr/jit/liveness.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ void Compiler::fgPerNodeLocalVarLiveness(GenTree* tree)
break;

case GT_STOREIND:
case GT_STORE_OBJ:
case GT_STORE_BLK:
case GT_STORE_DYN_BLK:
case GT_MEMORYBARRIER: // Similar to Volatile indirections, we must handle this as a memory def.
Expand Down Expand Up @@ -2019,8 +2018,7 @@ void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALAR
if (isDeadStore)
{
LIR::Use addrUse;
if (blockRange.TryGetUse(node, &addrUse) &&
(addrUse.User()->OperIs(GT_STOREIND, GT_STORE_BLK, GT_STORE_OBJ)))
if (blockRange.TryGetUse(node, &addrUse) && (addrUse.User()->OperIs(GT_STOREIND, GT_STORE_BLK)))
{
GenTreeIndir* const store = addrUse.User()->AsIndir();

Expand Down Expand Up @@ -2100,7 +2098,6 @@ void Compiler::fgComputeLifeLIR(VARSET_TP& life, BasicBlock* block, VARSET_VALAR
case GT_JMP:
case GT_STOREIND:
case GT_BOUNDS_CHECK:
case GT_STORE_OBJ:
case GT_STORE_BLK:
case GT_STORE_DYN_BLK:
case GT_JCMP:
Expand Down
Loading

0 comments on commit 7b662a7

Please sign in to comment.