Skip to content

Commit b35a21d

Browse files
authored
Document the C ABI for _BitInt and other types. (#240)
Document the C ABI for `_BitInt`, `_Complex`, `__int128_t`, and `__uint128_t`. These follow the ABI currently used by clang, to the best of my knowledge. Fixes #239.
1 parent 58cdfb4 commit b35a21d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

BasicCABI.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ General type | C Type | `sizeof` | Alignment (bytes) | Wasm Value Type
3838
Integer | `unsigned long` | 4 | 4 | i32
3939
Integer | `long long` / `signed long long` | 8 | 8 | i64
4040
Integer | `unsigned long long` | 8 | 8 | i64
41+
Integer | `__int128_t` | 16 | 16 | (none)
42+
Integer | `__uint128_t` | 16 | 16 | (none)
4143
Pointer | *`any-type *`* / *`any-type (*)()`* | 4 | 4 | i32
4244
Floating point | `float` | 4 | 4 | f32
4345
Floating point | `double` | 8 | 8 | f64
@@ -56,6 +58,13 @@ General type | C Type | `sizeof` | Alignment (bytes) | Wasm Value Type
5658
Otherwise, if a compiler supports such an `enum`, it would use `i64`
5759
for the `enum`.
5860
* Emscripten uses 8 byte alignment for `long double`.
61+
* `__int128_t` and `__uint128_t` are passed as two `i64`s in little-endian
62+
order, and are otherwise represented in the ABI as a struct containing two
63+
`i64` fields, in little-endian order.
64+
* `_Complex` types are represented in the ABI as a struct containing two
65+
corresponding floating-point fields, real and imaginary.
66+
* `_BitInt(N)` types are supported up to width 128 and are represented as the
67+
smallest same-signedness Integer type with at least as many bits.
5968

6069
**Aggregates and Unions**
6170

0 commit comments

Comments
 (0)