87 Commits

Author SHA1 Message Date
Jacob Young
78eb3c5617 bootstrap: support aarch64 in 32-bit mode
* `CMakeLists.txt`: support the weird `uname -m` output.
 * `CMakeLists.txt`: detect and use the C compiler's default arm mode.
 * cbe: support gcc with both `f128` and `u128` emulated.
 * std.os.linux.thumb: fix incorrectly passed asm inputs.
2023-07-04 15:47:07 -07:00
Jacob Young
2e6a6d7564 llvm/cbe: fix signed @mod/@divFloor computations
Closes #15636
2023-05-10 15:11:52 -04:00
Jacob Young
f1782c07a9 cbe: implement @extern 2023-04-25 13:42:10 -04:00
Jacob Young
f5cf732659 zig.h: add missing msvc atomics 2023-04-22 01:16:25 -04:00
Jacob Young
5feb27c126 zig.h: fix float negation 2023-04-21 23:08:48 -04:00
Jacob Young
d56c6c7791 cbe: implement 128-bit atomics support
* Disable 128-bit atomics for x86_64 generic (currently also baseline)
   because they require heavy abi agreement to correctly lower.
   ** This is a breaking change **
 * Enable 128-bit atomics for aarch64 in Sema since it just works.
2023-04-21 16:36:31 -04:00
Jacob Young
5afaaf865f zig.h: fix msvc abi for f128 with a gnu compiler 2023-04-21 16:36:31 -04:00
Jacob Young
e364627e3e cbe: fix float casts involving f16
Fixes bugs with a previous fix to the f16 abi on x86 darwin.
2023-04-21 16:36:31 -04:00
Jacob Young
b45bcd6420 cbe: fix f128 and c_longdouble abi
Fixes the abi of `f128` on darwin and/or aarch64.  Also, when `double`
and `long double` were the same size, we used to incorrectly define
`zig_c_longdouble` as `zig_f128`.
2023-04-21 16:36:31 -04:00
Jacob Young
d9596a128f zig.h: fix typos affecting msvc 2023-04-21 16:36:31 -04:00
Jacob Young
d98974e826 cbe: fix issues with atomic floats
Since the Zig language documentation claims support for `.Min` and
`.Max` in `@atomicRmw` with floats, allow in Sema and implement for both
the llvm and C backends.
2023-04-21 16:36:30 -04:00
Jacob Young
bf6fd9ae3f cbe: enable CI for std tests 2023-04-21 16:36:10 -04:00
Andrew Kelley
aa45854ec3 zig.h: fix typo for zig_trap definition 2023-04-08 09:54:32 -07:00
Andrew Kelley
ef5afbfcf4 zig.h: f16 fix for compiler_rt
See #15092
2023-04-06 08:40:02 -07:00
Andrew Kelley
f289277599 Merge remote-tracking branch 'origin/master' into llvm16 2023-04-05 22:05:31 -07:00
Jacob Young
5870ffeb82 compiler_rt: change the abi of f16 on mac to depend on the other type 2023-04-05 22:05:10 -07:00
Jacob Young
243848167b compiler_rt: attempt to fix f16 abi on mac with llvm 16 2023-04-05 22:05:06 -07:00
Jacob Young
9c3bea8482 zig.h: fix non-msvc warnings in msvc code 2023-03-30 12:07:12 +03:00
Jacob Young
e33dfc300e zig.h: implement zig_breakpoint and zig_trap for more targets 2023-03-07 12:46:35 -05:00
Jacob Young
77d06012c2 CBE: implement unsigned big int div and mod 2023-03-07 03:03:35 -05:00
Andrew Kelley
34a23db664 zig.h: lower trap to SIGTRAP instead of SIGILL 2023-03-05 17:11:46 -07:00
Jacob Young
c478c7609e CBE: implement vector operations
Also, bigint add and sub which is all I was actually trying to do.
2023-03-05 02:59:02 -05:00
Jacob Young
9e3a5ecd39 CBE: fix behavior test failures on msvc 2023-03-05 02:59:02 -05:00
Jacob Young
e96a0fd0a1 CBE: "compute" max int alignment the lazy way 2023-03-05 02:59:01 -05:00
Jacob Young
93d696e84e CBE: implement some big integer and vector unary operations 2023-03-05 02:59:01 -05:00
Jacob Young
a8f4ac2b94 CBE: implement big integer and vector comparisons 2023-03-05 02:59:01 -05:00
Jacob Young
874ae81f1b CBE: implement big integer literals 2023-03-05 02:59:01 -05:00
r00ster91
65368683ad add @trap builtin
This introduces a new builtin function that compiles down to something that results in an illegal instruction exception/interrupt.
It can be used to exit a program abnormally.

This implements the builtin for all backends.
2023-03-04 12:08:19 +01:00
Jacob Young
9d24d0354f CBE: fix MSVC diagnostics generated by the behavior tests
After this, the last MSVC warnings are in behavior/bugs/529.zig:
behavior.c(37971): warning C4133: 'function': incompatible types - from 'A__8479 *' to 'A__8474 *'
behavior.c(37974): warning C4133: 'function': incompatible types - from 'A__8480 *' to 'A__8474 *'
2023-02-23 20:30:59 -05:00
Jacob Young
a0d7fd162b CBE: support call attributes
* Support always_tail and never_tail/never_inline with a comptime callee using clang
 * Support never_inline using gcc
 * Support never_inline using msvc

Unfortunately, can't enable behavior tests because of the conditional support.
2023-02-23 10:54:26 -05:00
Jacob Young
57f6adf85d CBE: implement c varargs
Removed some backend test skip checks for things disabled in std.
2023-02-23 01:21:59 -05:00
Jacob Young
248fb40dcc CBE: fix windows test failures 2023-02-21 15:46:34 -05:00
Jacob Young
25a3c933b9 CBE: fix test failures 2023-02-21 02:32:49 -05:00
Jacob Young
b76fed8206 zig.h: get no int128 path working on non-msvc 2023-02-21 00:27:12 -05:00
Jacob Young
3eed197c95 CBE: use stdint.h types instead of zig_ prefixes
This requires manual defines before C99 which may not have stdint.h.

Also have update-zig1 leave a copy of lib/zig.h in stage1/zig.h, which
allows lib/zig.h to be updated without needing to update zig1.wasm.
Note that since the object already existed with the exact same contents,
this completely avoids repo bloat due to zig.h changes.
2023-02-20 23:59:48 -05:00
kcbanner
a9b68308b9 cbe: fixes for tls, support for not linking libc, and enabling tests
- cbe: Implement linksection support, to support TLS when not linking libc
- cbe: Support under-aligned variables / struct fields
- cbe: Support packed structs (in the C definition of packed)
- windows: Fix regression with x86 _tls_array
- compiler_rt: Add 128-bit atomics to compiler_rt
- tests: Re-enable threadlocal tests on cbe+windows, and llvm+x86
- tests: Re-enable f80 tests that now pass
- ci: change windows ci to run the CBE behaviour tests with -lc, to match how the compiler is bootstrapped
- update zig1.wasm
2023-01-29 15:04:13 -05:00
kcbanner
c7a9c28310 update zig1.wasm 2023-01-23 13:48:37 -05:00
kcbanner
77084093d8 cbe: handle building for -msvc using clang and -gnu using msvc 2023-01-23 13:48:37 -05:00
kcbanner
0d249e558a cbe: fixup handling of c_longdouble for msvc abi 2023-01-23 13:48:36 -05:00
kcbanner
a7209e7d12 cbe: fixup zig_export for x86 2023-01-23 13:48:36 -05:00
kcbanner
b22b84de9d cbe: fixup x86 atomics
- add zig_msvc_atomic_barrier()
- fix zig_msvc_atomic_load_p32
2023-01-23 13:48:36 -05:00
kcbanner
1aa2c32055 cbe: fixes for x86
- Emit calling convention
- Fix .Naked handling for msvc
- Add teb helper for x86
- Fix 128-bit shl implementation when rhs is >= 64
- Add 128-bit shl tests
2023-01-23 13:48:36 -05:00
Michael Dusan
db7b36f3fc zig.h: do not assume __GNUC__ is not clang (#2)
I missed this edit in 176940b5045ff0c9b20f9951dca34b2a1bb7edc0 .
2023-01-06 01:32:13 -05:00
Michael Dusan
176940b504 zig.h: do not assume __GNUC__ is not clang
A followup to 5bd69c655d9e04102c8a64ced1215c9d69f4f03f .

For compatibility purposes clang defines __GNUC__. This broke logic
where clang14 __has_builtin returns false but `|| defined(__GNUC__)`
made it true.

CI did not catch this because it uses clang15. However, bootstrapping
with latest apple compiler is clang14. We also want to support older
clang.
2023-01-05 15:25:35 -07:00
kcbanner
ee9a793d83 zig.h: fixup for -Wexpansion-to-defined 2023-01-04 02:23:15 -05:00
kcbanner
6d0c921379 cbe: revert movement of zig_float_from_repr to before float typedefs 2023-01-04 01:26:02 -05:00
Andrew Kelley
5bd69c655d zig.h: support GCC compilers that lack __has_builtin 2023-01-03 03:21:53 -05:00
kcbanner
45a55df12c cbe: fixups for -Wstrict-prototypes 2023-01-02 13:56:32 -07:00
kcbanner
cac652f81b cbe: fixup cpuid on non-msvc 2023-01-02 13:56:17 -07:00
kcbanner
ccf0ab0ef6 cbe: use callconv(.C) for zig.g stub functions, use zig.h function for windows teb instead of syscall 2023-01-02 13:56:11 -07:00