16879 Commits

Author SHA1 Message Date
ominitay
d978fdaa67
std.c.Wasi.Stat: use timespec 2022-02-13 20:40:44 +00:00
ominitay
3dd3c5063b
std.c.haiku: move Stat.crtime to Stat.birthtime 2022-02-13 20:40:44 +00:00
ominitay
f23005eba7
std.c.darwin.Stat: use timespec
Uses timespec for times in `Stat` instead of two `isize` fields per time. This matches the <sys/stat.h> header file.
2022-02-13 20:40:44 +00:00
Tw
2a73700c0f Fix preadv/pwritev bug on 64bit platform
Signed-off-by: Tw <wei.tan@intel.com>
2022-02-13 18:01:07 +00:00
Koakuma
55fa349ad9
Import SPARCv9 libunwind
Import LLVM's D32450/D116857 patch to enable unwinding support on
SPARCv9 systems.
2022-02-13 17:16:22 +02:00
Mateusz Radomski
b5f8fb85e6
Implement f128 @rem 2022-02-13 15:37:38 +02:00
Sebsatian Keller
f22443bb05
Fixed progress indicator for zig test (#10859)
Previously the progress displayed the first item as [0/x]. This was
misleading when x is the number of items. The first item should be
displayed as [1/x]
2022-02-13 15:19:33 +02:00
Cody Tapscott
f516e2c5b1 Simplify implementation of floorPowerOfTwo in std.math 2022-02-13 14:47:58 +02:00
Jacob G-W
3bbe6a28e0 stage2: add decltests 2022-02-13 14:42:20 +02:00
Andrew Kelley
0b7347fd18 move more behavior tests to the "passing" section 2022-02-12 21:35:29 -07:00
Andrew Kelley
c349191b75 organize behavior tests
moving towards disabling failing tests on an individual basis
2022-02-12 21:13:07 -07:00
Andrew Kelley
a005ac9d3c stage2: implement @popCount for SIMD vectors 2022-02-12 20:44:30 -07:00
Jakub Konka
16ec848d2a macho: put linker symlink for cache invalidation in zig-cache
Due to differences in where the output gets emitted in stage1 and stage2,
we were putting the symlink next to the binary rather than in `zig-cache`
directory when building with stage2.
2022-02-12 21:27:23 +01:00
Jakub Konka
d542a588c6 Skip @sqrt f80 test on freebsd 2022-02-12 21:24:18 +01:00
Jakub Konka
9643f32c99
Merge pull request #10861 from ziglang/f80
make f80 less hacky; lower as u80 on non-x86
2022-02-12 13:25:44 +01:00
Andrew Kelley
16076964d6 disable NaN f80 behavior tests
Let's get all these other bug fixes in and figure out f80 NaN later.
Looks like it's not working at comptime in master branch anyway.
2022-02-12 11:18:23 +01:00
Andrew Kelley
774f9bdb79 LLVM backend: disable failing aarch64 behavior test 2022-02-12 11:18:23 +01:00
Andrew Kelley
91508e10ab LLVM backend: handle unnamed structs when lowering array values
LLVM doesn't support lowering union values, so we have to use unnamed
structs to do it, which means any type that contains a union as an
element, even if it is nested in another type, has to have a mechanism
to detect when it can't be lowered normally and has to resort itself to
an unnamed struct.

This includes arrays.
2022-02-12 11:18:23 +01:00
Andrew Kelley
38236533f1 LLVM backend: avoid creating invalid LLVM types
Fixes assertions from creating i0 types which are not allowed in LLVM.
2022-02-12 11:18:23 +01:00
Andrew Kelley
ba31a9469f Sema: int casting to u0 returns const value
Also shift left with u0 rhs returns lhs even when lhs is runtime known.
2022-02-12 11:18:23 +01:00
Andrew Kelley
b92e1ab8cc stage1: override f80 alignment for i386-windows
Comment reproduced here:

Note the following u64 alignments:
  x86-linux:   4
  x86-windows: 8
LLVM makes x86_fp80 have the following alignment and sizes regardless
of operating system:
  x86_64: size=16, align=16
  x86:    size=12, align=4
However in Zig we override x86-windows to have size=16, align=16
in order for the property to hold that u80 and f80 have the same ABI size.

Fixes "error: destination type 'f80' has size 12 but source type 'u80'
has size 16" when trying to bitcast between f80 and u80 on i386-windows.
2022-02-12 11:18:23 +01:00
Andrew Kelley
d72f832b1e LLVM backend: call constPtrToInt instead of constBitCast
when appropriate. Avoids tripping an LLVM assertion.
2022-02-12 11:18:23 +01:00
Andrew Kelley
335c680cde LLVM backend: fix union with only 1 tag tripping llvm assertion 2022-02-12 11:18:23 +01:00
Andrew Kelley
1a8987fe7c CI: additionally test stage2 LLVM backend targeting aarch64-linux 2022-02-12 11:18:23 +01:00
Andrew Kelley
a024aff932 make f80 less hacky; lower as u80 on non-x86
Get rid of `std.math.F80Repr`. Instead of trying to match the memory
layout of f80, we treat it as a value, same as the other floating point
types. The functions `make_f80` and `break_f80` are introduced to
compose an f80 value out of its parts, and the inverse operation.

stage2 LLVM backend: fix pointer to zero length array tripping LLVM
assertion. It now checks for when the element type is a zero-bit type
and lowers such thing the same way that pointers to other zero-bit types
are lowered.

Both stage1 and stage2 LLVM backends are adjusted so that f80 is lowered
as x86_fp80 on x86_64 and i386 architectures, and identical to a u80 on
others. LLVM constants are lowered in a less hacky way now that #10860
is fixed, by using the expression `(exp << 64) | fraction` using llvm
constants.

Sema is improved to handle c_longdouble by recursively handling it
correctly for whatever the float bit width is. In both stage1 and
stage2.
2022-02-12 11:18:23 +01:00
Andrew Kelley
1c23321d03 stage1: fix softfloat not getting correct endianness
needed to include platform.h in more places so that LITTLEENDIAN will be
defined appropriately.

closes #10860
2022-02-12 11:18:23 +01:00
Andrew Kelley
166db1a3ed stage1: fix f80 size and alignment on x86 and arm
* F80Repr extern struct needs no explicit padding; let's match the
   target padding.
 * stage2: fix lowering of f80 constants.
 * stage1: decide ABI size and alignment of f80 based on alignment of
   u64. x86 has alignof u64 equal to 4 but arm has it as 8.
 * stage2: fix Value.floatReadFromMemory to use F80Repr
2022-02-12 11:18:23 +01:00
Andrew Kelley
f293fbbeaf stage2: LLVM backend: adjust replaceAllUsesWith usage
replaceAllUsesWith requires the type to be unchanged. So we bitcast
the new global to the old type and use that as the thing to replace
old uses.

Fixes an LLVM assertion found while troubleshooting #10837.
2022-02-12 11:18:23 +01:00
Jakub Konka
beb275b371 Revert "CI: upgrade both host and target tarballs to llvm 13.0.1 x86_64-macos"
This reverts commit 1072d8a0658d76415124ef6aac6842283316f243.
2022-02-12 11:17:41 +01:00
Jakub Konka
1072d8a065 CI: upgrade both host and target tarballs to llvm 13.0.1 x86_64-macos 2022-02-12 11:01:10 +01:00
Andrew Kelley
3fdbc3bba8 CI: upgrade x86_64-macos tarball to llvm 13.0.1 2022-02-12 01:09:13 -07:00
joachimschmidt557
2262640e8b stage2 ARM: lower const slices
Follow-up to e1a535360fb9ed08fc48018571b9702ab12a5876 for ARM

This also fixes some stack offset calculation bugs
2022-02-12 00:01:05 +01:00
Andrew Kelley
a5a7f0ff00 CI: upgrade x86_64-macos tarball to llvm 13.0.1 2022-02-11 15:57:44 -07:00
Jakub Konka
e1a535360f
Merge pull request #10862 from ziglang/elf-lower-slices
stage2: native backends: lower const slices
2022-02-11 15:02:17 +01:00
Jakub Konka
cad3e3e63a x64: enable more behavior tests 2022-02-11 12:49:06 +01:00
Jakub Konka
066758b1a2 macho: correctly lower slices incl reloc and rebase tracking
Match changes required to `Elf` linker, which enable lowering
of const slices on `MachO` targets.

Expand `Mir` instructions requiring the knowledge of the containing
atom - pass the symbol index into the linker's table from codegen
via mir to emitter, to then utilise it in the linker.
2022-02-11 12:16:32 +01:00
Jakub Konka
b9b1ab0240 elf: store pointer relocations indexed by containing atom
In `getDeclVAddr`, it may happen that the target `Decl` has not
been allocated space in virtual memory. In this case, we store a
relocation in the linker-global table which we will iterate over
when flushing the module, and fill in any missing address in the
final binary. Note that for optimisation, if the address was resolved
at the time of a call to `getDeclVAddr`, we skip relocating this
atom.

This commit also adds the glue code for lowering const slices in
the ARM backend.
2022-02-11 10:52:13 +01:00
Jakub Konka
08e2f5d083 codegen: handle lowering of const slice pointers 2022-02-11 10:52:13 +01:00
Andrew Kelley
f0400ad93e
Merge pull request #10857 from Luukdegram/wasm-tests
stage2: Wasm - implement field_ptr
2022-02-10 19:22:23 -05:00
Luuk de Gram
9c6d416bec
Activate passing behavior tests
This moves the single bugs behavior tests to the outer branch and disables the test cases
for all non-passing backends.
For the larger files, we move it up a single branch and disable it for the c backend.
All test cases that do pass for the c backend however, are enabled.
2022-02-10 21:40:06 +01:00
Luuk de Gram
0e2fcab334
wasm: Implement 'field_ptr' constants
This implements the `field_ptr` value for pointers. As the value only provides us with the index,
we must calculate the offset from the container type using said index. (i.e. the offset from a struct field at index 2).

Besides this, small miscellaneous fixes/updates were done to get remaining behavior tests passing:
 - We start the function table index at 1, so unresolved function pointers don't can be null-checked properly.
 - Implement genTypedValue for floats up to f64.
 - Fix zero-sized arguments by only creating `args` for non-zero-sized types.
 - lowerConstant now works for all decl_ref's.
 - lowerConstant properly lowers optional pointers, so `null` pointers are lowered to `0`.
2022-02-10 21:40:06 +01:00
Jakub Konka
e139c41fd8 stage2: handle truncate to signed non-pow-two integers 2022-02-10 15:05:12 +01:00
Andrew Kelley
c10fdde5a6 stage2: LLVM backend: make unnamed struct globals
LLVM union globals have to be lowered as unnamed structs if the
non-most-aligned field is the active tag. In this case it bubbles up so
that structs containing unions have the same restriction.

This fix needs to be applied to optionals and other callsites of
createNamedStruct.

The bug fixed in this commit was revealed in searching for
the cause of #10837.
2022-02-10 00:27:02 -07:00
Jakub Konka
57357c43e3 elf: pad out file to the required size when init data
We need to pad out the file to the required maximum size equal the
final section's offset plus the section's size. We only need to
this when populating initial metadata and only when section header
was updated.
2022-02-10 08:12:02 +01:00
Andrew Kelley
65c812842d freestanding libc: fix missing functions
In the previous commit I got mixed up and cut-pasted instead of
copy-pasting. In this commit I made c_stage1.zig additionally included
for stage1 and everything else included for both. So moving forward we
move stuff over from c_stage1.zig to c.zig instead of copying.
2022-02-09 19:13:53 -07:00
Andrew Kelley
f2f1c63daf stage2: add log and logf to freestanding libc 2022-02-09 18:52:32 -07:00
Sebsatian Keller
f5471299d8
stage 1: improve error message if error union is cast to payload (#10770)
Also: Added special error message for for `?T` to `T` casting
2022-02-09 20:35:53 -05:00
Andrew Kelley
1e5a494603 Sema: implement comptime ptr store to optional payload
and error union payload
2022-02-09 18:29:51 -07:00
John Schmidt
7f0cf395aa stage2: implement all builtin floatops for f{16,32,64}
- Merge `floatop.zig` and `floatop_stage1.zig` since most tests now pass
  on stage2.
- Add more behavior tests for a bunch of functions.
2022-02-09 20:29:41 -05:00
Andrew Kelley
44b5fdf326 Revert "ci: azure: split build-and-test step"
This reverts commit 846eb701821a3f2af514bbad770478e3276b2d89.

This did not properly translate the upload portion of the CI script to
powershell which broke our CI pipeline.
2022-02-09 18:26:56 -07:00