- all Phase 0 tasks done; exit criterion met (41 conformance tests, run records compared across two runs) - RFC 0004 Amendment 1 documents format-0 additions; status stays Proposed pending owner acceptance - open question Q-019: non-terminating programs in test tooling - README/CONTRIBUTING: current state and `aji run`
105 lines
2.6 KiB
Markdown
105 lines
2.6 KiB
Markdown
# RFC 0004: AIR Instruction Set
|
|
|
|
Status: Proposed
|
|
Target: Aji 0.1
|
|
|
|
## Goal
|
|
|
|
AIR should be small enough for complete semantic definitions to fit in an agent context while remaining expressive enough for systems software.
|
|
|
|
## Principle
|
|
|
|
Do not add instructions because they make source syntax convenient. Add an AIR instruction only when it represents a distinct semantic/verifier operation.
|
|
|
|
## Initial instruction families
|
|
|
|
### Pure values
|
|
|
|
```text
|
|
const copy move
|
|
integer arithmetic
|
|
bitwise operations
|
|
comparisons
|
|
casts with explicit failure/semantics
|
|
```
|
|
|
|
### Control
|
|
|
|
```text
|
|
br cbr switch ret trap guard assert
|
|
```
|
|
|
|
### Memory
|
|
|
|
```text
|
|
borrow.ref borrow.mut borrow.end
|
|
load store
|
|
slice.make slice.sub
|
|
mem.copy mem.zero
|
|
```
|
|
|
|
### Ownership
|
|
|
|
```text
|
|
own.alloc own.free
|
|
region.create region.alloc region.reset region.destroy
|
|
island.create island.alloc island.freeze
|
|
arc.clone arc.release
|
|
```
|
|
|
|
### Resources and calls
|
|
|
|
```text
|
|
call call.indirect intrinsic.call
|
|
resource.consume
|
|
```
|
|
|
|
### Concurrency
|
|
|
|
```text
|
|
task.scope.begin task.scope.end
|
|
task.spawn task.join task.cancel
|
|
thread.spawn thread.join
|
|
channel.send channel.recv
|
|
mutex.lock mutex.unlock
|
|
rwlock.read rwlock.write
|
|
atomic.load atomic.store atomic.rmw atomic.cmpxchg atomic.fence
|
|
```
|
|
|
|
## Required metadata
|
|
|
|
Each opcode definition must declare:
|
|
|
|
```text
|
|
syntax
|
|
operand types
|
|
result types
|
|
ownership transfer
|
|
borrow transfer
|
|
memory read/write set
|
|
sync relation
|
|
required effect
|
|
required capability
|
|
trap cases
|
|
verifier transfer function
|
|
interpreter behavior
|
|
```
|
|
|
|
## Binary stability
|
|
|
|
AIR opcodes should receive stable numeric IDs only after the semantics of v0.1 freeze. Before then, text AIR is the safer canonical interchange for development.
|
|
|
|
## Amendment 1 — format version 0 (Phase 0)
|
|
|
|
Status: Proposed, implemented in the reference implementation.
|
|
|
|
Format version 0 (spec 07 §8, spec 07a) realizes the "pure values" and "control" families and adds the following, each a distinct verifier operation rather than syntax sugar:
|
|
|
|
| Addition | Why it is a distinct operation |
|
|
|---|---|
|
|
| `cast.widen` / `cast.checked` / `cast.wrap` | the three cast semantics differ in verifier obligations (static losslessness, runtime trap, none) |
|
|
| `struct.make`, `struct.get` | nominal aggregate construction and projection need their own typing rules |
|
|
| `enum.make`, `enum.switch` | tagged unions: exhaustiveness is checked by the CFG pass and payloads bind to block parameters, so no separate "get payload" instruction can observe an inactive variant |
|
|
|
|
Not yet realized: memory, ownership, resources, calls through values (`call.indirect`) and concurrency families; they arrive with their phases and are specified in spec 07a first.
|