Skip to content

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

Open
Heath123 wants to merge 5 commits intoturbolent:mainfrom
Heath123:alignment-hints
Open

Option to pass alignment hints to the load and store macros#67
Heath123 wants to merge 5 commits intoturbolent:mainfrom
Heath123:alignment-hints

Conversation

@Heath123
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

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

Copy link
Copy Markdown
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?

Co-authored-by: Bastian Müller <bastian@turbolent.com>
@turbolent
Copy link
Copy Markdown
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