Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add GenTree::GetLayout
  • Loading branch information
SingleAccretion committed Jun 13, 2022
commit 5ce4274a393d6615f2225a8ac83cd270624c162d
37 changes: 35 additions & 2 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -567,14 +567,47 @@ void Compiler::fgWalkAllTreesPre(fgWalkPreFn* visitor, void* pCallBackData)
}
}

//-----------------------------------------------------------
// GetLayout: Get the struct layout for this node.
//
// Arguments:
// compiler - The Compiler instance
//
// Return Value:
// The struct layout of this node; it must have one.
//
// Notes:
// This is the "general" method for getting the layout,
// the more efficient node-specific ones should be used
// in case the node's oper is known.
//
ClassLayout* GenTree::GetLayout(Compiler* compiler) const
{
assert(varTypeIsStruct(TypeGet()));

switch (OperGet())
{
case GT_LCL_VAR:
return compiler->lvaGetDesc(AsLclVar())->GetLayout();

case GT_LCL_FLD:
return AsLclFld()->GetLayout();

case GT_OBJ:
case GT_BLK:
return AsBlk()->GetLayout();

default:
unreached();
}
}

//-----------------------------------------------------------
// CopyReg: Copy the _gtRegNum/gtRegTag fields.
//
// Arguments:
// from - GenTree node from which to copy
//
// Return Value:
// None
void GenTree::CopyReg(GenTree* from)
{
_gtRegNum = from->_gtRegNum;
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/gentree.h
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,8 @@ struct GenTree
return gtType;
}

ClassLayout* GetLayout(Compiler* compiler) const;

#ifdef DEBUG
genTreeOps gtOperSave; // Only used to save gtOper when we destroy a node, to aid debugging.
#endif
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/jit/jit.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,8 @@ typedef unsigned IL_OFFSET;

const IL_OFFSET BAD_IL_OFFSET = 0xffffffff;

const unsigned BAD_VAR_NUM = UINT_MAX;
const unsigned BAD_VAR_NUM = UINT_MAX;
const uint16_t BAD_LCL_OFFSET = UINT16_MAX;

// Code can't be more than 2^31 in any direction. This is signed, so it should be used for anything that is
// relative to something else.
Expand Down