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

Define operators for physaddr and virtaddr #668

Open
Timmmm opened this issue Jan 6, 2025 · 2 comments · May be fixed by #672
Open

Define operators for physaddr and virtaddr #668

Timmmm opened this issue Jan 6, 2025 · 2 comments · May be fixed by #672
Labels
refactor Code clean up

Comments

@Timmmm
Copy link
Collaborator

Timmmm commented Jan 6, 2025

The new physaddr and virtaddr types are quite nice, but they do make some code uglier. For example instead of

handle_mem_exception(vaddr - offset), e);

we have to do

handle_mem_exception(virtaddr(virtaddr_bits(vaddr) - offset), e);

I think we can overload + and - (and maybe others) so that they work with physaddr and virtaddr too.

@Timmmm Timmmm added the refactor Code clean up label Jan 6, 2025
@trdthg
Copy link
Contributor

trdthg commented Jan 7, 2025

I tried this before, but due to the order of file dependencies, the result was not very ideal

The current compilation order is PRELUDE = prelude.sail ... prelude_mem.sail

- General overloads are defined in prelude.sail
- If you want to overload operator for physaddr and virtaddr, you must define it inprelude_mem.sail or after it, possibly in a new prelude_operator.sail which looks messy.

I wonder will sail support syntax like overload operator xxx += { }?

I found that overload runs in append way

@Timmmm
Copy link
Collaborator Author

Timmmm commented Jan 7, 2025

Yeah it's described here. I think adding them just after the newtypes is fine.

@trdthg trdthg linked a pull request Jan 7, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Code clean up
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants