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

Are field/index accesses compile-time known? #1323

Open
jaehyun1ee opened this issue Nov 2, 2024 · 1 comment
Open

Are field/index accesses compile-time known? #1323

jaehyun1ee opened this issue Nov 2, 2024 · 1 comment

Comments

@jaehyun1ee
Copy link
Contributor

Section 18.1 lists compile-time known and local compile-time known values.

The list does not include field access with . and index access with [ ].
But there are use cases in the p4c test suite that expects such.

// struct.p4, struct1.p4
const T t = { 32s10, 32s20 };
const int<32> x = t.t1;
// tuple3.p4
const tuple<bit<32>, bit<32>> t = { 0, 1 };
const bit<32> f = t[0];

How about adding the following cases to the list in 18.1?

For a field access, accessing a field of a local compile-time known / compile-time known expression results in a local-compile time known / compile-time known value, respectively.

For indexing a tuple-type expression,

index \ tuple local compile-time known compile-time known
local compile-time known local compile-time known compile-time known
compile-time known compile-time known compile-time known
@jafingerhut
Copy link
Collaborator

The extra cases of compile-time known and local compile-time known values that you list look correct to me, and seem reasonable to explicitly document in the spec.

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

2 participants