buffer.alloca
← buffer dialect
Create a fixed-frame scratch buffer root in an allocatable memory space. Each execution produces a distinct storage identity; identical allocas must not be commoned. The byte length is the requested physical byte count for the execution. Targets requiring a static frame reserve its proven finite non-negative maximum. base_alignment is the minimum byte alignment of the root storage base. Target lowering determines which allocatable spaces are legal for the containing program kind. The execution frame owns the allocation; the result borrows that storage and has no explicit release obligation. An explicit pool selects the backing allocation resource; memory_space remains an access requirement that resource must satisfy. The pool is borrowed and does not extend the allocation lifetime. Omitting it uses the containing execution's allocation resource for that space, which must be unambiguous before materialization. Lowering cannot replace an explicit pool with an ambient allocation resource.
Operation contract
| Property |
Value |
| Semantic phase |
executable |
| Ownership effects |
borrow pool (by_value), borrowed result |
Signature
| Kind |
Name |
Type |
Cardinality |
Description |
| Operand |
pool |
pool |
optional |
Borrowed resource providing the allocation's backing storage. |
| Operand |
byte_length |
offset |
required |
Requested physical byte length of the scratch root. |
| Result |
result |
buffer |
required |
Fresh opaque scratch storage root. Produces a fresh allocation. |
| Attribute |
base_alignment |
i64 |
required |
Minimum byte alignment of the root storage base. |
| Attribute |
memory_space |
enum MemorySpace |
required |
Allocatable scratch memory space for the root. |
Examples
%scratch = buffer.alloca<workgroup> align(64) %bytes : buffer
%packets = buffer.alloca<workgroup> pool(%tile_memory) align(64) %bytes : buffer