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.
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 asstash
, 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.