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

Option to pass alignment hints to the load and store macros #67

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Heath123
Copy link
Contributor

@Heath123 Heath123 commented Mar 30, 2023

Closes #65

This won't work with the original w2c2_base.h, but a custom one should be able to make use of it.

Questions:

  • Should I validate whether the hints have valid values, or just assume it's valid like I am now?
  • Should I be doing result->align = 1 << align; in the instruction reader like I have here, leave it as-is in the instruction struct and do that as the C source file is written, or write it to the file as-is and have the macros do it?

@Heath123
Copy link
Contributor Author

Oops, looks like I made a mistake that got caught by the test cases again

Copy link
Owner

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice, thank you for adding support for this!

Maybe the default header file can include alignment aware variants of the load/store functions (e.g. i32_store -> i32_store_a/i32_store_aligned) and wasmCWriteLoadExpr/wasmCWriteStoreExpr could generate calls to those functions if the flag is set?

w2c2/instruction.c Outdated Show resolved Hide resolved
Co-authored-by: Bastian Müller <bastian@turbolent.com>
@turbolent
Copy link
Owner

Sorry, I missed your questions:

Should I validate whether the hints have valid values, or just assume it's valid like I am now?

No, you don't need validate it. w2c2 does not do any validation and assumes the input module is valid, as other tools are already available to validate modules. That keeps w2c2 simple.

Should I be doing result->align = 1 << align; in the instruction reader like I have here, leave it as-is in the instruction struct and do that as the C source file is written, or write it to the file as-is and have the macros do it?

The way it is implemented at the moment seems fine to me 👍

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.

Use alignment hints
2 participants