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

Add RISC-V extension constraints #63

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

tpudlik
Copy link

@tpudlik tpudlik commented Mar 2, 2023

Mini design document: https://docs.google.com/document/d/18pFUSWH0vN-R0AfIC5Wk5yWzE3Rhe0miDI5TgPRj2s4/edit#

This PR is intended for discussion, I don't think it's necessarily ready to be merged. (In particular, I'm not sure if privileged execution modes are correctly modeled; see the design document.)

@aiuto

constraint_value(
name = "riscv64",
constraint_setting = ":cpu",
)

# Base integer instruction set, 64-bit, 16 registers.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any opinion from the riscv expert about what the (inevitable) 64-bit 32-register core will be called? Or, to put it backwards, is the 'e' an official name or is it just what we have been using internally?

@aiuto aiuto requested a review from katre March 21, 2023 02:04
package(
default_visibility = ["//visibility:public"],
)

Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like this should have a description of the intended usage. That you create a platform from the riscv base and add in the settings that are relevant to the particular silicon you have.
That is, I want to capture the design choice somewhere to serve as documentation.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this needs documentation and examples. Possibly a README.md as well.

licenses(["notice"])

package(
default_visibility = ["//visibility:public"],
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs

default_applicable_licenses = ["//:license"],

@@ -0,0 +1,972 @@
# Constraint settings describing RISC-V extensions.
licenses(["notice"])
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can leave this out. It is a no-op for Bazel and now internally with Blaze.

package(
default_visibility = ["//visibility:public"],
)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this needs documentation and examples. Possibly a README.md as well.

)

# Does the CPU possess extension M (multiplication and division)?
constraint_setting(
Copy link
Member

Choose a reason for hiding this comment

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

Normally I think macros are more work than help, but these are so regular that I think a macro which creates the setting and both constraints would be helpful.

I'm also not wild about this style for (effectively) boolean constraints, but that's the system we have. Any suggestions for https://docs.google.com/document/d/1LD4uj1LJZa98C9ix3LhHntSENZe5KE854FNL5pxGNB4/edit?usp=sharing about a better way to model these?

constraint_setting = "Zicsr_setting",
)

# Does the CPU possess extension Zifencei (Control and Status Register)?
Copy link
Member

Choose a reason for hiding this comment

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

How is this "Control and Status Register" different from :Zicsr, above?


# Does the CPU possess extension M (multiplication and division)?
constraint_setting(
name = "M_setting",
Copy link
Member

Choose a reason for hiding this comment

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

I assume RISC-V publishes a canonical list of these, and what they mean. Can we link it here?

Also, I worry slightly about upper case target names given the existence of case-insensitive file systems (like on macos). In this case it seems unlikely to conflict, but we should probably stick with all lower case as a general rule.

default_constraint_value = ":no_Zbc",
)

# CPU does possess the B extension
Copy link
Member

Choose a reason for hiding this comment

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

Definitely a macro would help here, the comments are out of sync with the target names.

)

# CPU does not possess the Zihintpause extension
constraint_value(
Copy link
Member

Choose a reason for hiding this comment

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

Having stopped being able to read this, it'd be nice if we had a process to generate this file from a canonical source and check that in, rather than have someone go though and update by hand. Possibly a macro would make things enough clearer, though, that that wouldn't be needed.

constraint_value(
name = "riscv32",
constraint_setting = ":cpu",
)

# Base integer instruction set, 32-bit, 16 registers.
constraint_value(
name = "riscv32e",
Copy link
Member

Choose a reason for hiding this comment

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

Is this (and the riscv64e, below) sufficiently different from riscv32 to need a new cpu constraint, or is it better modeled as :riscv32 plus a new extension?

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.

3 participants