Skip to content
Merged
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
10 changes: 8 additions & 2 deletions src/coreclr/jit/codegenwasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,16 @@ void CodeGen::genCodeForNegNot(GenTreeOp* tree)
void CodeGen::genCodeForLclAddr(GenTreeLclFld* lclAddrNode)
{
assert(lclAddrNode->OperIs(GT_LCL_ADDR));
bool FPBased;
unsigned lclNum = lclAddrNode->GetLclNum();
unsigned lclOffset = lclAddrNode->GetLclOffs();

GetEmitter()->emitIns_I(INS_local_get, EA_PTRSIZE, WasmRegToIndex(GetFramePointerReg()));
GetEmitter()->emitIns_S(INS_I_const, EA_PTRSIZE, lclAddrNode->GetLclNum(), lclAddrNode->GetLclOffs());
GetEmitter()->emitIns(INS_I_add);
if ((lclOffset != 0) || (compiler->lvaFrameAddress(lclNum, &FPBased) != 0))
{
GetEmitter()->emitIns_S(INS_I_const, EA_PTRSIZE, lclNum, lclOffset);
GetEmitter()->emitIns(INS_I_add);
}
genProduceReg(lclAddrNode);
}

Expand Down
19 changes: 11 additions & 8 deletions src/coreclr/jit/regallocwasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ void WasmRegAlloc::RewriteLocalStackStore(GenTreeLclVarCommon* lclNode)
{
// At this point, the IR is already stackified, so we just need to find the first node in the dataflow.
// TODO-WASM-TP: this is nice and simple, but can we do this more efficiently?
GenTree* op = lclNode->Data();
GenTree* value = lclNode->Data();
GenTree* op = value;
GenTree::VisitResult visitResult;
do
{
Expand All @@ -187,23 +188,25 @@ void WasmRegAlloc::RewriteLocalStackStore(GenTreeLclVarCommon* lclNode)
});
} while (visitResult == GenTree::VisitResult::Abort);

// TODO-WASM-RA: figure out the address mode story here. Right now this will produce an address not folded
// into the store's address mode. We can utilize a contained LEA, but that will require some liveness work.
uint16_t offset = lclNode->GetLclOffs();
lclNode->SetOper(GT_LCL_ADDR);
lclNode->ChangeType(TYP_I_IMPL);
lclNode->AsLclFld()->SetLclOffs(offset);

GenTree* store;
GenTreeFlags indFlags = GTF_IND_NONFAULTING | GTF_IND_TGT_NOT_HEAP;
if (lclNode->TypeIs(TYP_STRUCT))
{
store = m_compiler->gtNewStoreBlkNode(lclNode->GetLayout(m_compiler), lclNode, lclNode->Data(), indFlags);
store = m_compiler->gtNewStoreBlkNode(lclNode->GetLayout(m_compiler), lclNode, value, indFlags);
}
else
{
store = m_compiler->gtNewStoreIndNode(lclNode->TypeGet(), lclNode, lclNode->Data(), indFlags);
store = m_compiler->gtNewStoreIndNode(lclNode->TypeGet(), lclNode, value, indFlags);
}
CurrentRange().InsertAfter(lclNode, store);
CurrentRange().Remove(lclNode);

// TODO-WASM-RA: figure out the address mode story here. Right now this will produce an address not folded
// into the store's address mode. We can utilize a contained LEA, but that will require some liveness work.
lclNode->SetOper(GT_LCL_ADDR);
lclNode->ChangeType(TYP_I_IMPL);
CurrentRange().InsertBefore(op, lclNode);
}

Expand Down
Loading