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

Storage classes read-once #5

Open
3 tasks
jdpage opened this issue Dec 6, 2017 · 0 comments
Open
3 tasks

Storage classes read-once #5

jdpage opened this issue Dec 6, 2017 · 0 comments

Comments

@jdpage
Copy link
Collaborator

jdpage commented Dec 6, 2017

  • decide if we want this or not
  • add it to the spec
  • implement it

Names may need work. (Maybe also an argument for allowing multiple storage classes to be combined, though some of the combinations don't make sense. Perhaps make this a storage-adjective?)

Description

read-once is a storage class for function-local variables which behaves the same way as stash, except it can only be present in an rvalue exactly once in the function body.

Rationale

If a variable is used in only one spot in the function body, the value can be stored directly in the instruction stream. For pointers, this means that they can be dereferenced using the efficient Absolute and Absolute-Indexed addressing modes; for 8-bit values, they can be used as Immediate arguments to instructions.

Alternatives

Depending on whether or not one considers generating self-modifying code in order to use a faster addressing mode an "optimization", this may be a better candidate for annotations than a storage class, particularly for 8-bit values. That said, because it changes the semantics of the variable and causes the compiler to enforce those semantics, it seems to fit better as a storage class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant