Implement iota keyword that would have similar function as in Go (or APL before), and generate consecutive unsigned integers.
The iota keyword would be used to enumerate register indexes in blocks, and in instructions wrapped in [].
Iota enumeration in blocks starts from 1 (to prevent accidental returns), is scoped, and incremented by 1 after each use.
Iota enumeration in [] starts from 0, is scoped, and incremented by 1 after each use.
The following examples are provided as explanation.
Use-case 1: enumerating register indexes in blocks
Frees programmers from manually assigning register indexes to names.
.function: foo/0
.name: iota foo
.name: iota bar
istore iota 42 ; iota can also be used outside of .name: directives
Implement
iota
keyword that would have similar function as in Go (or APL before), and generate consecutive unsigned integers.The
iota
keyword would be used to enumerate register indexes in blocks, and in instructions wrapped in[]
. Iota enumeration in blocks starts from 1 (to prevent accidental returns), is scoped, and incremented by 1 after each use. Iota enumeration in[]
starts from 0, is scoped, and incremented by 1 after each use. The following examples are provided as explanation.Use-case 1: enumerating register indexes in blocks
Frees programmers from manually assigning register indexes to names.
expands to
Use-case 2: enumerating function parameters in frames
Frees programmers from manually managing frame slots.
expands to
Use-case 3: enumerating parameters in called function
Current
iota
value can be manipulated using.iota: <value>
directive, and enables third use-case.expands to