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

Enable GT_CALL with long ret types for x86 RyuJIT#5890

Merged
michellemcdaniel merged 1 commit into
dotnet:masterfrom
michellemcdaniel:x86LongCallFinal
Jun 23, 2016
Merged

Enable GT_CALL with long ret types for x86 RyuJIT#5890
michellemcdaniel merged 1 commit into
dotnet:masterfrom
michellemcdaniel:x86LongCallFinal

Conversation

@michellemcdaniel
Copy link
Copy Markdown

  1. Enables genMultiRegCallStoreToLocal for x86 RyuJIT. Forces long return
    types to be stored to the stack after returning from a call.

  2. Update lvaPromoteLongVars to not promote a long if it is a multi reg
    arg or ret.

  3. Adds NYI for call arguments that are longs and contain adds or
    subtracts. We are currently producing the wrong order of operations so
    that we can push the argument immediately after performing the arithmetic.
    We will do the hi adc/sbb before the carry bit has been set by doing the
    lo operation.

  4. Adds an NYI for morphing a node into a call node if the call will have
    a long return type.

  5. Moves the logic for forcing var = call() for calls with long return
    types to lower::DecomposeNode().

@michellemcdaniel
Copy link
Copy Markdown
Author

@CarolEidt @sivarv PTAL
/cc: @dotnet/jit-contrib

Comment thread src/jit/lower.cpp
GenTreePtr* treePtr = nullptr;
parent = tree->gtGetParent(&treePtr);

GenTreeStmt* asgStmt = comp->fgInsertEmbeddedFormTemp(treePtr);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding a TODO here to handle the possibility that the new asgStmt will become a top-level statement, carrying existing embedded statements with it. This would be a good candidate for using the CreateTemporary method in @mikedn's PR #5871

Copy link
Copy Markdown
Member

@sivarv sivarv Jun 21, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CarolEidt can new asgStmt become a top-level stmt since the check above is "if (parent !=nullptr)" that is GT_CALL node has a parent? The case where GT_CALL node is a top-level stmt without any parent, there is no need to force IR to be var=call. Did I mis-understood anything?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a good point. So I don't think a TODO is required here. A comment would be useful to the effect that, since this is known to have a parent, we needn't worry about creating a new top-level statement.

@briansull
Copy link
Copy Markdown

Looks Good

Comment thread src/jit/importer.cpp
unsigned retRegCount = retTypeDesc->GetReturnRegCount();
// must be a long returned in two registers
assert(retRegCount == 2);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function header comment needs to be updated, since this routine is just initializing return type descriptor of a call node. Also should we rename this method to be representative of its new functionality (e.g. impInitCallReturnTypeDesc())

Note that right now impFixupCallStructReturn() is also initializing return type desc of a call node for unix amd64. @briansull would need to add similar code for Arm64 case. In future when we add support for arrm32 this routine would come handy.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated the function name and header. Should we also change the logic of impFixupCallStructReturn to call this function (and make it available to more than just TARGET_X86)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would like that change. But I am equally fine if you don't want to club that change with this PR.

Comment thread src/jit/lower.cpp Outdated
GenTree* parent = data->parent;
if (parent != nullptr)
{
// We do not need to force var = call() if the call is a top-level node.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this comment above 388. The fact that we are forcing IR to be var=call only if GT_CALL node has a parent indicates that GT_CALL node is not a top-level stmnt.

@sivarv
Copy link
Copy Markdown
Member

sivarv commented Jun 22, 2016

Looks good.

@CarolEidt
Copy link
Copy Markdown

LGTM

1) Enables genMultiRegCallStoreToLocal for x86 RyuJIT. Forces long return
types to be stored to the stack after returning from a call.

2) Update lvaPromoteLongVars to not promote a long if it is a multi reg
arg or ret.

3) Adds NYI for call arguments that are longs and contain adds or
subtracts. We are currently producing the wrong order of operations so
that we can push the argument immediately after performing the arithmetic.
We will do the hi adc/sbb before the carry bit has been set by doing the
lo operation.

4) Adds an NYI for morphing a node into a call node if the call will have
a long return type.

5) Moves the logic for forcing var = call() for calls with long return
types to lower::DecomposeNode().
@michellemcdaniel
Copy link
Copy Markdown
Author

@dotnet-bot test this please

@michellemcdaniel michellemcdaniel merged commit 26d4a8c into dotnet:master Jun 23, 2016
@michellemcdaniel michellemcdaniel deleted the x86LongCallFinal branch June 23, 2016 15:14
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Enable GT_CALL with long ret types for x86 RyuJIT

Commit migrated from dotnet/coreclr@26d4a8c
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants