Robin Voetter
9c20449cc5
wasm: lower min/max for floats to compiler_rt
...
The min and max builtins in Zig have some intricate behavior
related to floats, that is not replicated with the min and max
wasm instructions or using simple select operations. By lowering
these instructions to compiler_rt, handling around NaNs is done
correctly.
See also https://github.com/WebAssembly/design/issues/214
2023-10-15 14:00:32 +02:00
Xavier Bouchoux
d5991ee7ca
codegen/wasm: fix non-byte-sized signed integer comparison
2023-10-14 10:23:36 +02:00
Xavier Bouchoux
27a19908ed
codegen/wasm: fix tuple member offset computation
...
It didn't account for field alignement.
2023-10-14 10:23:36 +02:00
Andrew Kelley
aaf46187ab
Merge pull request #17391 from xxxbxxx/load-i4
...
codegen/llvm: truncate padding bits when loading a non-byte-sized value
2023-10-09 22:06:49 -07:00
Jacob Young
922b5b5453
x86_64: implement 128-bit integer multiply and divide
2023-10-09 05:23:23 -04:00
Jacob Young
d559c61902
x86_64: implement @min and @max for 128-bit integers
2023-10-09 03:11:41 -04:00
Jacob Young
21948d7540
x86_64: implement @abs of 128-bit integers
2023-10-09 03:11:41 -04:00
Jacob Young
a96c08c1d1
x86_64: implement struct field value for register pairs
2023-10-09 03:11:40 -04:00
Jacob Young
f28b1657aa
x86_64: implement 128-bit integer shifts in registers
2023-10-09 03:09:01 -04:00
Luuk de Gram
54e7f58fcb
Merge pull request #17438 from Luukdegram/issue-17436
...
wasm - fix `@tagName` for signed enums
2023-10-08 21:58:35 +02:00
Luuk de Gram
8e836cb59a
wasm: correctly lower signed value in @tagName
2023-10-08 15:18:40 +02:00
Xavier Bouchoux
85315bb535
codegen/wasm: fix intcast accross 32-bits boundary
2023-10-08 11:37:49 +02:00
Jacob Young
b5dedd7c00
x86_64: implement @mulAdd of floats for baseline
2023-10-08 04:41:55 -04:00
Jacob Young
35c9b717f7
x86_64: implement @rem for floats
2023-10-08 04:41:55 -04:00
Jacob Young
3bf9a8feb5
x86_64: fix @divTrunc and @divFloor of f16
2023-10-08 04:41:55 -04:00
Jacob Young
9fc9235ac8
x86_64: fix undersized vector binary operations
2023-10-08 04:41:55 -04:00
Jacob Young
f6e027da32
x86_64: fix conversions between floats and 128-bit integers
2023-10-08 04:41:55 -04:00
Jacob Young
b8f00ae337
x86_64: implement @abs for some integer vector types
2023-10-08 04:41:55 -04:00
Jacob Young
24d76500d2
x86_64: fix bitcast from f80
2023-10-08 04:41:55 -04:00
Jacob Young
24c67992e0
x86_64: hack around silent f80 miscompilations
...
The x87 kind sucks.
2023-10-07 19:47:46 -04:00
Jacob Young
b19fd485b1
x86_64: improve inline assembly support
...
* instruction prefixes
* mnemonic fixes
* labels
* memory operands
* read-write constraint modifier
* register and memory alternative constraint
2023-10-07 16:02:01 -04:00
Jacob Young
7436f3efc9
x86_64: implement C var args
2023-10-07 02:10:34 -04:00
Jacob Young
20b4401cde
x86_64: implement negation and @abs for f80
...
Also implement live-outs since the x87 requires so much care around
liveness tracking.
2023-10-07 00:29:17 -04:00
Jacob Young
5aeb13c350
x86_64: implement f80 movement
2023-10-07 00:29:17 -04:00
Jacob Young
9f8b2ff9e2
x86_64: fix C abi typos
2023-10-07 00:29:17 -04:00
Jacob Young
54b2d6f072
x86_64: implement C abi for everything else
2023-10-05 04:38:25 -04:00
Jacob Young
cc6694a323
x86_64: implement C abi for f128
2023-10-05 04:10:38 -04:00
Jacob Young
c2ec518fe2
x86_64: refactor calling convention checks
2023-10-05 00:19:25 -04:00
Jacob Young
b4427bc300
plan9: refactor debug info
...
The main goal is to stop depending on `emit.lower.target`.
2023-10-05 00:19:25 -04:00
Jacob Young
5a35734a48
x86_64: fix abi bit/byte mixups
2023-10-05 00:19:21 -04:00
Jacob Young
644d943861
x86_64: implement 128-bit integer comparisons
2023-10-04 16:26:56 -04:00
Jacob Young
2a5335d7b6
x86_64: implement C abi for 128-bit integers
2023-10-04 14:42:35 -04:00
Jacob Young
9748096992
x86_64: fix various crashes
2023-10-04 14:42:35 -04:00
Luuk de Gram
de78caf9c4
wasm: implement lowering anon decls
2023-10-03 12:49:29 -07:00
Andrew Kelley
c0b5512544
compiler: start handling anonymous decls differently
...
Instead of explicitly creating a `Module.Decl` object for each anonymous
declaration, each `InternPool.Index` value is implicitly understood to
be an anonymous declaration when encountered by backend codegen.
The memory management strategy for these anonymous decls then becomes to
garbage collect them along with standard InternPool garbage.
In the interest of a smooth transition, this commit only implements this
new scheme for string literals and leaves all the previous mechanisms in
place.
2023-10-03 12:12:50 -07:00
Xavier Bouchoux
405705cb76
codegen: fix byte-aligned field offsets in unaligned nested packed structs
2023-10-03 05:34:19 +00:00
Xavier Bouchoux
62d178e91a
codegen: fix field offsets in packed structs
...
* add nested packed struct/union behavior tests
* use ptr_info.packed_offset rather than trying to duplicate the logic from Sema.structFieldPtrByIndex()
* use the container_ptr_info.packed_offset to account for non-aligned nested structs.
* dedup type.packedStructFieldBitOffset() and module.structPackedFieldBitOffset()
2023-10-03 06:39:20 +02:00
Jacob Young
da335f0ee4
x86_64: implement float @sqrt builtin
2023-10-01 15:09:52 -04:00
Jacob Young
fbe5bf469e
x86_64: implement float arithmetic builtins
2023-10-01 15:09:52 -04:00
Jacob Young
1eb023908d
x86_64: implement float round builtins
2023-10-01 15:09:52 -04:00
Jacob Young
c3042cbe12
x86_64: add missing caller preserved regs
...
All allocatable registers have to be either callee preserved or caller
preserved.
2023-10-01 15:09:52 -04:00
Jacob Young
8470652f10
x86_64: implement float compare and cast builtins
2023-10-01 15:09:52 -04:00
Jacob Young
6d5cbdb863
behavior: cleanup floatop tests
2023-10-01 15:09:52 -04:00
Jacob Young
3bd1b9e15f
x86_64: implement and test unary float builtins
2023-10-01 15:09:52 -04:00
Jakub Konka
af40bce08a
x86_64: emit R_X86_64_GOT32 for non-PIC GOT references
2023-10-01 21:09:35 +02:00
Andrew Kelley
1c02e58fc0
Revert "compiler: don't use @abs builtin yet"
...
This reverts commit 21780899eb17a0cb795ff40e5fae6556c38ea13e.
After this commit, a version of the compiler which supports the new
`@abs` builtin is required.
2023-09-27 11:23:28 -07:00
Andrew Kelley
21780899eb
compiler: don't use @abs builtin yet
...
This commit can be used to rebuild zig1.wasm
2023-09-27 11:21:59 -07:00
antlilja
6a29646a55
Rename @fabs to @abs and accept integers
...
Replaces the @fabs builtin with a new @abs builtins which accepts
floats, signed integers and vectors of said types.
2023-09-27 11:15:53 -07:00
Andrew Kelley
221295b7db
wasm: fix regression of C ABI
...
It seems the webassembly backend does not want the exception that
`structFieldAlignmentExtern` makes for 128-bit integers. Perhaps that
logic should be modified to check if the target is wasm.
Without this, this branch fails the C ABI tests for wasm, causing this:
```
wasm-ld: warning: function signature mismatch: zig_struct_u128
>>> defined as (i64, i64) -> void in cfuncs.o
>>> defined as (i32) -> void in test-c-abi-wasm32-wasi-musl-ReleaseFast.wasm.o
```
2023-09-21 22:25:58 -07:00
Andrew Kelley
55bc8a7fa9
compiler: fix compilation for 32-bit targets
2023-09-21 15:27:25 -07:00