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

Parameters are not substituted in annotations #919

Open
vbgl opened this issue Oct 2, 2024 · 2 comments
Open

Parameters are not substituted in annotations #919

vbgl opened this issue Oct 2, 2024 · 2 comments

Comments

@vbgl
Copy link
Member

vbgl commented Oct 2, 2024

The following program is rejected by the compiler:

param int N = 4;
#[stacksize = N]
export fn xor(reg u32 x y) -> reg u32 {
  stack u8[N] s;
  s[u32 0] = x;
  x = y;
  y = s[u32 0];
  x ^= y;
  return x;
}

I think it would be nice to be able to use parameters in annotations. It might be necessary to provide means to disambiguate identifiers (e.g., here N could be the name of a function).

@bgregoir
Copy link
Contributor

bgregoir commented Oct 2, 2024

This will be clearly nice to have. How will you do the change in the annotations ?
By doing a global string replacement ?
#[s1 = ... @param(N) ... ] --> #[s1 = ... 4 ...]
I don't say that we should use this syntax. I just want to understand how we can do it ?

@vbgl
Copy link
Member Author

vbgl commented Oct 2, 2024

I’d rather say term rewriting instead of string replacement, but yes, that’s the idea.

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