-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Introduce GenTreeDebugOperKind
#64498
Changes from all commits
acbccab
4f83527
06259c2
2cf4425
98b25b2
61a2668
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,7 +85,7 @@ enum genTreeOps : BYTE | |
// The following enum defines a set of bit flags that can be used | ||
// to classify expression tree nodes. | ||
// | ||
enum genTreeKinds | ||
enum GenTreeOperKind | ||
{ | ||
GTK_SPECIAL = 0x00, // special operator | ||
GTK_LEAF = 0x01, // leaf operator | ||
|
@@ -95,12 +95,28 @@ enum genTreeKinds | |
GTK_KINDMASK = (GTK_SPECIAL | GTK_LEAF | GTK_UNOP | GTK_BINOP), // operator kind mask | ||
GTK_SMPOP = (GTK_UNOP | GTK_BINOP), | ||
|
||
GTK_COMMUTE = 0x08, // commutative operator | ||
GTK_EXOP = 0x10, // Indicates that an oper for a node type that extends GenTreeOp (or GenTreeUnOp) | ||
// by adding non-node fields to unary or binary operator. | ||
GTK_NOVALUE = 0x20, // node does not produce a value | ||
GTK_NOTLIR = 0x40, // node is not allowed in LIR | ||
GTK_NOCONTAIN = 0x80, // this node is a value, but may not be contained | ||
GTK_COMMUTE = 0x08, // commutative operator | ||
GTK_EXOP = 0x10, // Indicates that an oper for a node type that extends GenTreeOp (or GenTreeUnOp) | ||
// by adding non-node fields to unary or binary operator. | ||
GTK_NOVALUE = 0x20, // node does not produce a value | ||
|
||
GTK_MASK = 0xFF | ||
}; | ||
|
||
// The following enum defines a set of bit flags that describe opers for the purposes | ||
// of DEBUG-only checks. This is separate from the above "GenTreeOperKind"s to avoid | ||
// making the table for those larger in Release builds. However, it resides in the same | ||
// "namespace" and so all values here must be distinct from those in "GenTreeOperKind". | ||
// | ||
enum GenTreeDebugOperKind | ||
{ | ||
DBK_FIRST_FLAG = GTK_MASK + 1, | ||
|
||
DBK_NOTHIR = DBK_FIRST_FLAG, // This oper is not supported in HIR (before rationalization). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also have "early HIR" in the compiler, i. e. HIR before morph: |
||
DBK_NOTLIR = DBK_FIRST_FLAG << 1, // This oper is not supported in LIR (after rationalization). | ||
DBK_NOCONTAIN = DBK_FIRST_FLAG << 2, // This oper produces a value, but may not be contained. | ||
|
||
DBK_MASK = ~GTK_MASK | ||
}; | ||
|
||
/*****************************************************************************/ | ||
|
@@ -878,8 +894,11 @@ struct GenTree | |
public: | ||
// The register number is stored in a small format (8 bits), but the getters return and the setters take | ||
// a full-size (unsigned) format, to localize the casts here. | ||
CLANG_FORMAT_COMMENT_ANCHOR; | ||
|
||
#ifdef DEBUG | ||
bool canBeContained() const; | ||
#endif | ||
|
||
// for codegen purposes, is this node a subnode of its parent | ||
bool isContained() const; | ||
|
@@ -1073,34 +1092,6 @@ struct GenTree | |
return true; | ||
} | ||
|
||
bool IsLIR() const | ||
{ | ||
if ((OperKind(gtOper) & GTK_NOTLIR) != 0) | ||
{ | ||
return false; | ||
} | ||
|
||
switch (gtOper) | ||
{ | ||
case GT_NOP: | ||
// NOPs may only be present in LIR if they do not produce a value. | ||
return IsNothingNode(); | ||
|
||
case GT_ADDR: | ||
{ | ||
// ADDR ndoes may only be present in LIR if the location they refer to is not a | ||
// local, class variable, or IND node. | ||
GenTree* location = gtGetOp1(); | ||
genTreeOps locationOp = location->OperGet(); | ||
return !location->IsLocal() && (locationOp != GT_CLS_VAR) && (locationOp != GT_IND); | ||
} | ||
|
||
default: | ||
// All other nodes are assumed to be correct. | ||
return true; | ||
} | ||
} | ||
|
||
// LIR flags | ||
// These helper methods, along with the flag values they manipulate, are defined in lir.h | ||
// | ||
|
@@ -1645,6 +1636,20 @@ struct GenTree | |
} | ||
|
||
#ifdef DEBUG | ||
static const GenTreeDebugOperKind gtDebugOperKindTable[]; | ||
|
||
static GenTreeDebugOperKind DebugOperKind(genTreeOps oper) | ||
{ | ||
assert(oper < GT_COUNT); | ||
|
||
return gtDebugOperKindTable[oper]; | ||
} | ||
|
||
GenTreeDebugOperKind DebugOperKind() const | ||
{ | ||
return DebugOperKind(OperGet()); | ||
} | ||
|
||
bool NullOp1Legal() const | ||
{ | ||
assert(OperIsSimple()); | ||
|
@@ -1683,6 +1688,17 @@ struct GenTree | |
} | ||
} | ||
|
||
bool OperIsLIR() const | ||
{ | ||
if (OperIs(GT_NOP)) | ||
{ | ||
// NOPs may only be present in LIR if they do not produce a value. | ||
return IsNothingNode(); | ||
} | ||
|
||
return (DebugOperKind() & DBK_NOTLIR) == 0; | ||
} | ||
|
||
bool OperSupportsReverseOps() const; | ||
static bool RequiresNonNullOp2(genTreeOps oper); | ||
bool IsValidCallArgument(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would have been possible to make the values here part of
GenTreeOperKind
, but I think having a separate enum is clearer overall.