Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Change binary op tree display (#20045)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedn authored and CarolEidt committed May 29, 2019
1 parent 90e7b68 commit 2eeeac5
Showing 1 changed file with 38 additions and 62 deletions.
100 changes: 38 additions & 62 deletions src/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,16 @@ enum IndentChars
ICTop,
ICMiddle,
ICDash,
ICEmbedded,
ICTerminal,
ICError,
IndentCharCount
};

// clang-format off
// Sets of strings for different dumping options vert bot top mid dash embedded terminal error
static const char* emptyIndents[IndentCharCount] = { " ", " ", " ", " ", " ", "{", "", "?" };
static const char* asciiIndents[IndentCharCount] = { "|", "\\", "/", "+", "-", "{", "*", "?" };
static const char* unicodeIndents[IndentCharCount] = { "\xe2\x94\x82", "\xe2\x94\x94", "\xe2\x94\x8c", "\xe2\x94\x9c", "\xe2\x94\x80", "{", "\xe2\x96\x8c", "?" };
static const char* emptyIndents[IndentCharCount] = { " ", " ", " ", " ", " ", "", "?" };
static const char* asciiIndents[IndentCharCount] = { "|", "\\", "/", "+", "-", "*", "?" };
static const char* unicodeIndents[IndentCharCount] = { "\xe2\x94\x82", "\xe2\x94\x94", "\xe2\x94\x8c", "\xe2\x94\x9c", "\xe2\x94\x80", "\xe2\x96\x8c", "?" };
// clang-format on

typedef ArrayStack<Compiler::IndentInfo> IndentInfoStack;
Expand Down Expand Up @@ -115,9 +114,6 @@ struct IndentStack
case Compiler::IndentInfo::IINone:
printf(" ");
break;
case Compiler::IndentInfo::IIEmbedded:
printf("%s ", indents[ICEmbedded]);
break;
case Compiler::IndentInfo::IIArc:
if (index == 0)
{
Expand Down Expand Up @@ -10592,10 +10588,6 @@ void Compiler::gtDispTree(GenTree* tree,
indentStack->Push(IINone);
lowerArc = IIArc;
break;
case IIEmbedded:
indentStack->Push(IIEmbedded);
lowerArc = IIEmbedded;
break;
case IINone:
indentStack->Push(IINone);
lowerArc = IINone;
Expand All @@ -10606,53 +10598,12 @@ void Compiler::gtDispTree(GenTree* tree,
}
}

// Special case formatting for PHI nodes -- arg lists like calls.

if (tree->OperGet() == GT_PHI)
{
gtDispNode(tree, indentStack, msg, isLIR);
gtDispCommonEndLine(tree);

if (!topOnly)
{
if (tree->gtOp.gtOp1 != nullptr)
{
IndentInfo arcType = IIArcTop;
for (GenTreeArgList* args = tree->gtOp.gtOp1->AsArgList(); args != nullptr; args = args->Rest())
{
if (args->Rest() == nullptr)
{
arcType = IIArcBottom;
}
gtDispChild(args->Current(), indentStack, arcType);
arcType = IIArc;
}
}
}
return;
}

/* Is it a 'simple' unary/binary operator? */

const char* childMsg = nullptr;

if (tree->OperIsSimple())
{
if (!topOnly)
{
if (tree->gtGetOp2IfPresent())
{
// Label the childMsgs of the GT_COLON operator
// op2 is the then part

if (tree->gtOper == GT_COLON)
{
childMsg = "then";
}
gtDispChild(tree->gtOp.gtOp2, indentStack, IIArcTop, childMsg, topOnly);
}
}

// Now, get the right type of arc for this node
if (myArc != IINone)
{
Expand Down Expand Up @@ -10854,21 +10805,46 @@ void Compiler::gtDispTree(GenTree* tree,

gtDispCommonEndLine(tree);

if (!topOnly && tree->gtOp.gtOp1)
if (!topOnly)
{

// Label the child of the GT_COLON operator
// op1 is the else part

if (tree->gtOper == GT_COLON)
if (tree->gtOp.gtOp1 != nullptr)
{
childMsg = "else";
if (tree->OperIs(GT_PHI))
{
for (GenTreeArgList* args = tree->gtGetOp1()->AsArgList(); args != nullptr; args = args->Rest())
{
gtDispChild(args->Current(), indentStack, (args->Rest() == nullptr) ? IIArcBottom : IIArc);
}
}
else
{
// Label the child of the GT_COLON operator
// op1 is the else part

if (tree->gtOper == GT_COLON)
{
childMsg = "else";
}
else if (tree->gtOper == GT_QMARK)
{
childMsg = " if";
}
gtDispChild(tree->gtOp.gtOp1, indentStack,
(tree->gtGetOp2IfPresent() == nullptr) ? IIArcBottom : IIArc, childMsg, topOnly);
}
}
else if (tree->gtOper == GT_QMARK)

if (tree->gtGetOp2IfPresent())
{
childMsg = " if";
// Label the childMsgs of the GT_COLON operator
// op2 is the then part

if (tree->gtOper == GT_COLON)
{
childMsg = "then";
}
gtDispChild(tree->gtOp.gtOp2, indentStack, IIArcBottom, childMsg, topOnly);
}
gtDispChild(tree->gtOp.gtOp1, indentStack, IIArcBottom, childMsg, topOnly);
}

return;
Expand Down

0 comments on commit 2eeeac5

Please sign in to comment.