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 +: slices #1316

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

add +: slices #1316

wants to merge 1 commit into from

Conversation

ChrisDodd
Copy link
Contributor

No description provided.

@ChrisDodd ChrisDodd requested a review from jafingerhut October 12, 2024 01:22
@ChrisDodd
Copy link
Contributor Author

I'm unclear whether these changes need to be also in the asciidoc version, or if that happens automatically. Or perhaps we should wait until after the switchover to asciidoc and do it only there.

@jafingerhut
Copy link
Collaborator

I think it is worth discussing at the next LDWG meeting, exactly when Madoko -> AsciiDoc conversion happens.

Fortunately, for text paragraphs with little or no markup, it usually makes no difference. That said, the changes are so extensive for Madoko->AsciiDoc that I expect if that change is made before this PR, some small changes may be required in this PR. I think small changes to a PR like this to update it will not be wasted effort.

@@ -3489,6 +3489,11 @@ Bit-strings also support the following operations:
The effect of this statement is to set bits `H` through `L` (inclusive of
both) of `e` to the bit-pattern represented by `x`, and leaves all other bits
of `e` unchanged. A slice of an unsigned integer is an unsigned integer.
A slice may also be specified as `[L+:W]` where L is the lowest bit of the slice
and W is the width of the slice. In this case, only W must be a non-negative
local compile-time known numeric value. L must also be a numeric value and
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add markup to this occurrence of L, i.e. L with backticks

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also for the earlier occurrence of W in the paragraph.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this form of bit-slicing expected to work for values of type int<W>, too? If so, it might need to be mentioned explicitly in the section on operations on type int<W>. It seems to me reasonable to refer to the explanation in the section on bit<W> operations rather than copying and pasting, but also good to mention that the result is always of type bit<W>, which I think is what is specified for [hi:lo] bit slices on type int<W>.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The int<W> description was just a copy of the whole paragraph from here, so I shortened that to just refer to the bitstring description.

Copy link
Contributor

@vlstill vlstill left a comment

Choose a reason for hiding this comment

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

Looks good to me, except we should add wording that prohibits negative bit indices.

Comment on lines 3494 to 3496
local compile-time known numeric value. L must also be a numeric value and
some architectures may require it to be compile-time known. Some architectures
may allow variable indexing.
Copy link
Contributor

Choose a reason for hiding this comment

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

This wording currently allows L to be negative (e.g. either negative int literal, or int<N> expression which can have a negative value). A way out would be to say that its type must be either int, in which cast it must be non-negative, or bit<N>-expression. I think it would make sense to restrict this, as slices on negative bit index don't make sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, this is tricky. I added some verbiage to require non-negative in-range values, but only require an error message for constants, as it may be tricky to do that for variable values, and we don't have any way of dealing with it at runtime.

Signed-off-by: Chris Dodd <[email protected]>
@jafingerhut
Copy link
Collaborator

jafingerhut commented Nov 14, 2024

@ChrisDodd Sorry for the inconvenience, but we have, after several months of planning, transitioned the P4 language specification source from Madoko to AsciiDoc. Thus most or all of your PRs will need to be updated so that they apply to that version. Hopefully this should be fairly straightforward, e.g. by looking at examples of how things like section headings, bullet items, etc. are marked up in the latest version of the file P4-16-spec.adoc

If you have questions on how to change things for AsciiDoc, feel free to ask. Note that creating a new PR with similar changes as this PR might be easier than updating this PR.

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