Skip to content
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

[llvm] Let real function support returning struct #6614

Merged
merged 16 commits into from
Nov 24, 2022

Conversation

lin-hitonami
Copy link
Contributor

@lin-hitonami lin-hitonami commented Nov 15, 2022

Issue: #602 #6590

Brief Summary

Only supports scalar struct (every element in the struct is a scalar) for now.

This PR does the following things:

  1. Let FuncCallStmt return the real_func_ret_struct * result buffer instead of returning the return value directly.
  2. Add GetElementStmt and GetElementExpression to get the i-th return value in a result buffer
  3. Add StructType.from_real_func_ret to construct the returned struct to the StructType in Python

Will add support for nested struct and matrix in struct in the following PRs.

@netlify
Copy link

netlify bot commented Nov 15, 2022

Deploy Preview for docsite-preview ready!

Name Link
🔨 Latest commit 4bf53eb
🔍 Latest deploy log https://app.netlify.com/sites/docsite-preview/deploys/637d9d2846a4780009b0f137
😎 Deploy Preview https://deploy-preview-6614--docsite-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@lin-hitonami lin-hitonami changed the title [llvm] Let real function support struct [llvm] Let real function support returning struct Nov 16, 2022
@lin-hitonami lin-hitonami marked this pull request as ready for review November 18, 2022 08:05
@bobcao3
Copy link
Collaborator

bobcao3 commented Nov 20, 2022

Using U64 array types and doing pointer conversion is really bad. This prohibits the downstream compiler to do any sort of optimization on this array (because of pointer conversions), and it uses a lot of register space & causes larger spilling issue.

@lin-hitonami
Copy link
Contributor Author

Using U64 array types and doing pointer conversion is really bad. This prohibits the downstream compiler to do any sort of optimization on this array (because of pointer conversions), and it uses a lot of register space & causes larger spilling issue.

Yeah, please look at the Possible Improvement section of #6590 , I will compile it into a real struct in the future.

@lin-hitonami
Copy link
Contributor Author

/rebase

@taichi-gardener
Copy link
Contributor

Rebase failed, please resolve the conflicts manually.

@lin-hitonami
Copy link
Contributor Author

Constructed the result buffer directly into a llvm::StructType thanks to @bobcao3 .

Copy link
Contributor

@ailzhang ailzhang left a comment

Choose a reason for hiding this comment

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

Awesome thanks!

@lin-hitonami lin-hitonami merged commit f640b00 into taichi-dev:master Nov 24, 2022
@lin-hitonami lin-hitonami deleted the real_func_struct branch November 24, 2022 02:49
PGZXB added a commit that referenced this pull request Dec 19, 2022
Issue: #4401, #6614

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
PGZXB added a commit to PGZXB/taichi that referenced this pull request Dec 19, 2022
Issue: taichi-dev#4401, taichi-dev#6614

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels pushed a commit to quadpixels/taichi that referenced this pull request May 13, 2023
Issue: taichi-dev#602 taichi-dev#6590

### Brief Summary
Only supports scalar struct (every element in the struct is a scalar)
for now.

This PR does the following things:
1. Let `FuncCallStmt` return the `real_func_ret_struct *` result buffer
instead of returning the return value directly.
2. Add `GetElementStmt` and `GetElementExpression` to get the i-th
return value in a result buffer
3. Add `StructType.from_real_func_ret` to construct the returned struct
to the `StructType` in Python

Will add support for nested struct and matrix in struct in the following
PRs.

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
quadpixels pushed a commit to quadpixels/taichi that referenced this pull request May 13, 2023
Issue: taichi-dev#4401, taichi-dev#6614

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants