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

[Question] Multi-value Return using Tuple #6569

Open
bbbshaw opened this issue May 3, 2024 · 3 comments
Open

[Question] Multi-value Return using Tuple #6569

bbbshaw opened this issue May 3, 2024 · 3 comments

Comments

@bbbshaw
Copy link

bbbshaw commented May 3, 2024

I am building a project using C API. I have some questions regarding the multi-value return.

Suppose I want to construct a function with ( i32 i32 i32) as return values.

Q1: How should I define the type for both the call expression and return type of the function itself? Should I use BinaryenTypeCreate() to construct the type for both?

Q2: If I want to set the tuple as a local variable, should I reuse the type from BinaryenTypeCreate()?

Q3: If I want to set the tuple as a global variable, should I pass the result from BinaryenTypeCreate() to BinaryenAddGlobal() as the type?

Q3: I am modifying an existing function, is there any API I can use to add an extra local variable or modify the type of an existing local variable?

@kripken
Copy link
Member

kripken commented May 8, 2024

Q1-Q3: Yes. Types are handles to types, so you can pass them around like that.

Q4: BinaryenFunctionAddVar adds a variable. I don't think we have a method to modify an existing one atm.

@bbbshaw
Copy link
Author

bbbshaw commented May 18, 2024

Hi,

Thanks for your reply.

I call the BinaryenModuleValidate() to validate the generated module which uses the tuple feature. It reports error like:
unexpected false: Tuples are not allowed unless multivalue is enabled, on
Fatal: DWARF + multivalue is not yet complet
How should I fix this error?

@kripken
Copy link
Member

kripken commented May 20, 2024

The first is fixed by enabling multivalue, see BinaryenModuleSetFeatures().

For the second, you can either remove DWARF with --strip-dwarf as part of the wasm-opt invocation, or you can use a newer Binaryen as we did actually fix that recently (last few weeks - not in a release yet, but in main).

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

No branches or pull requests

2 participants