Types
This page describes the type system used by SBBE for its intermediate representation.
SBBE has an extremely simple type system, putting the onus on the frontend to ensure that types are used correctly. There are no user-defined types, no structs or arrays, and no type qualifiers (like const or volatile). The type system is designed to be as simple as possible while still being able to represent the necessary data for most programs.
| Type | Size | Description |
|---|---|---|
i8 | 1 byte | 8-bit integer |
i16 | 2 bytes | 16-bit integer |
i32 | 4 bytes | 32-bit integer |
i64 | 8 bytes | 64-bit integer |
f32 | 4 bytes | 32-bit IEEE 754 float |
f64 | 8 bytes | 64-bit IEEE 754 float |
ptr | target | 4 bytes (32-bit) or 8 bytes (64-bit) |
v128 | 16 bytes | 128-bit SIMD vector |
void | 0 | No value (return types only) |
Integers
You can use i8, i16, i32, and i64 for all integer types. Signedness is encoded into instructions (either through mnemonic macros or dedicated opcodes) rather than the type, so i32 is a single type used by both signed and unsigned instructions.
Future versions of SBBE may add additional integer types (like
i128ori256) or the ability to define custom integer types, likei9,i24, etc…
Floating Point
You can use f32 and f64 for 32-bit and 64-bit floating point types, respectively. These types follow the IEEE 754 standard for floating point representation. The f16 type is not currently supported, but is planned as part of our GPU support effort.
Pointers
The ptr type is used for pointers and addresses. It is a target-sized type, meaning it will be 32 bits on a 32-bit target and 64 bits on a 64-bit target. The ptr type is opaque and does not have any associated operations other than loading and storing values from memory. Pointer arithmetic and other operations are handled through dedicated instructions rather than being encoded into the type system.
Vectors
The v128 type represents a 128-bit SIMD vector. The interpretation of the lanes (e.g., 4x i32, 2x f64, 16x i8) is determined by the instruction operating on the vector, not by the type itself. This follows the same philosophy as integer signedness: the type is just a bag of bits, and the instruction gives it meaning.
SIMD instructions use lane descriptors like i32x4 or f64x2 to specify how the 128 bits are partitioned. These are not types in the SBBE type system. They are instruction operands encoded in the argument field, similar to how scalar instructions encode their type. A v128 value on the stack has no inherent lane layout; you can operate on the same value as i32x4 in one instruction and f32x4 in the next.
| Descriptor | Lanes | Lane width |
|---|---|---|
i8x16 | 16 | 8-bit integer |
i16x8 | 8 | 16-bit integer |
i32x4 | 4 | 32-bit integer |
i64x2 | 2 | 64-bit integer |
f32x4 | 4 | 32-bit float |
f64x2 | 2 | 64-bit float |
See the Instruction Set page for the full list of SIMD instructions.
Void
The void type is used exclusively in function signatures to indicate that a function does not return a value. It cannot appear on the operand stack, in variable declarations, or in the constant table.