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

Refactor haveExt() & sys_enable_ext() functions #495

Open
Timmmm opened this issue Jun 14, 2024 · 3 comments
Open

Refactor haveExt() & sys_enable_ext() functions #495

Timmmm opened this issue Jun 14, 2024 · 3 comments

Comments

@Timmmm
Copy link
Collaborator

Timmmm commented Jun 14, 2024

I think the haveExtension() functions are a bit confusingly named. It's unclear whether they mean that the CPU supports the extension, or if it is currently enabled (which are not necessarily the same if you have writeable misa). I believe the answer is the latter, and there are a few sys_enable_extension() functions which actually dictate whether the extension is supported. That function only exists for some extensions though.

This is confusing. I think we should do the following:

  1. Rename all haveExtension() functions to extensionEnabled().
  2. Rename all sys_enable_extension() functions to sys_support_extension() or sys_extension_supported().
  3. Add sys_extension_supported() functions corresponding to all the haveExtension() functions, so they are 1:1. Initially we can just hard-code the result rather than adding CLI arguments.
  4. Update legalize_misa() to use the sys_extension_supported() functions (even if they are hard-coded to true).
@Timmmm Timmmm mentioned this issue Jun 14, 2024
@arichardson
Copy link
Collaborator

I agree that this separation makes a lot of sense. Not sure it really matters but I wonder if we can use a common prefix for the enabled checks instead of a suffix? enable<Ext> isn't particularly nice but at least more explicit that haveXXX. I guess we could also use something like canUse<Ext>, is<Ext>Enabled

@Timmmm
Copy link
Collaborator Author

Timmmm commented Jun 20, 2024

Yeah I was thinking exactly the same thing - common prefix is definitely nicer but I couldn't think of a good way to word it that makes sense.

@jrtc27
Copy link
Collaborator

jrtc27 commented Jun 20, 2024

I'd rather see the extensions become a (scattered) enum that gets passed to haveExt/isExtEnabled/whatever (scattered) functions.

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

3 participants