32 Commits

Author SHA1 Message Date
LemonBoy
9b7d9c72b0 stage1: Initial implementation of @extern 2020-11-20 22:32:43 +01:00
Tadeo Kondrak
6b9dc82fa5
stage1: Compile error instead of falling back to C for unsupported cc 2020-11-19 13:59:11 +02:00
LemonBoy
2b7781d82a stage1: Fix undefined assignment for bitfields
Prevents silent memory corruption.

Closes #7055
2020-11-18 21:49:39 -08:00
Andrew Kelley
02a4e5a4bf
Merge pull request #6385 from LemonBoy/callocator
std: Make C allocator respect the required alignment
2020-11-18 20:16:57 -08:00
LemonBoy
bef140c0a2 stage1: Add architecture-specific clobbers to asm()
We're basically following Clang's lead, add the necessary clobbers to
minimize the risk of generating wrong code.
2020-11-18 13:08:04 +02:00
LemonBoy
fa27420b72 stage1: Fix asyncCall with non-abi-aligned arguments
Make the code used to calculate the variable slot index into the frame
match what's done during the structure layout calculation.

Prevents a few nasty LLVM errors when such types are passed around.
2020-11-17 15:55:12 -08:00
Alexandros Naskos
6e2e747b0b
Merge pull request #7112 from LemonBoy/fix-7104
stage1: Fix generation of pass-by-value args in async fns
2020-11-16 09:12:42 +02:00
LemonBoy
7ebbc717c0 stage1: Fix generation of pass-by-value args in async fns
The mismatch between the argument slot type in the frame structure and
the one used in the store operation made the generated code write
garbage over the nearby fields.

Fixes #7104
2020-11-14 15:30:06 +01:00
LemonBoy
211feea914 stage1: Disambiguate Wasm imports with same name
Closes #7088
2020-11-13 16:32:42 -05:00
LemonBoy
b52a28a802 stage1: Ask LLVM to produce compact code in ReleaseSize mode
Let's follow what Clang does for -Oz and apply the `minsize` and
`optsize` attributes by default.

Closes #7048
Supersedes #7077
2020-11-13 12:25:13 -05:00
LemonBoy
5872ae5111 stage1: Fix crash in comptime struct generation
Using the gen_index rather than the src_index is needed to handle
structures containing zero-sized or comptime only types.

Closes #7027
2020-11-11 15:35:19 +02:00
LemonBoy
e00356d6b1 stage1: Print correct error message for vector @intCast 2020-11-09 18:24:48 -05:00
LemonBoy
4664eae1e4 stage1: Fix type mapping for c_longdouble
A quick and dirty job to let the compiler use the correct size and
alignment.
2020-11-05 16:10:15 +01:00
LemonBoy
0d6a7088dc stage1: Implement Add/Mul reduction operators 2020-11-01 14:30:31 -07:00
Andrew Kelley
e6ac082437
Merge pull request #6744 from LemonBoy/intcast-vec
stage1: Implement `@intCast` between vectors
2020-10-22 17:36:18 -04:00
LemonBoy
2f465761bb stage1: Implement @intCast between vectors
Explicit and implicit integer casts on vector types are now supported
and follow the same rules as their scalar counterparts.

Implicit float casts are accidentally supported, `@floatCast` is still
not vector-aware.
2020-10-19 20:05:09 +02:00
LemonBoy
2a256d5ea0 stage1: Fix type-checking of unary neg for vector types
Validate the vector element type as done for the scalar case.

Fixes #6708
2020-10-17 21:08:39 -04:00
LemonBoy
f78380b936 stage1: Don't ask LLVM to emit misaligned memcpy
Pay close attention to the RHS type alignment when rendering an
assignment op as it may differ from the LHS pointer one.

This problem was noticed when debugging a CI failure in #6648: due to
sheer luck the misalignment caused a segfault on macos that was also
reproduced locally.

I tried to write a small test case but it turned out to be a daunting
task as I couldn't manage to trigger the problem consistently (and stop
the optimizer from simplifying everything). Patches welcome.
2020-10-16 18:39:48 -04:00
LemonBoy
0570df69b1 stage1: Fix missing runtime safety check for intToPtr
Elide the alignment check if the pointer alignment is one, the null
check must be preserved as it depends on the pointer type.

Fixes #6667
2020-10-14 00:05:50 -04:00
Andrew Kelley
8b7539bd95 Merge remote-tracking branch 'origin/master' into llvm11
Conflicts:
  src/clang.zig

Master branch renamed an enum; this branch gave it an explicit tag type
and explicitly initialized values. This commit combines the changes
together.
2020-10-08 15:47:45 -07:00
Tadeo Kondrak
0a6863a267 Remove .Cold calling convention.
This isn't a stable, defined calling convention, so it shouldn't be
grouped in with the others.

Closes https://github.com/ziglang/zig/issues/6556
2020-10-07 04:31:20 -04:00
Andrew Kelley
b5a36f676b Merge remote-tracking branch 'origin/master' into llvm11
Conflicts:
  cmake/Findllvm.cmake

The llvm11 branch changed 10's to 11's and master branch added the
"using LLVM_CONFIG_EXE" help message, so the resolution was to merge
these changes together.

I also added a check to make sure LLVM is built with AVR enabled, which
is no longer an experimental target.
2020-10-07 00:46:05 -07:00
Andrew Kelley
939b4860ef
Merge pull request #6472 from alexnask/add_some_frees
Add a few missing deallocations of temporaries to stage1
2020-10-05 04:56:58 -04:00
LemonBoy
22b5e47839 stage1: Implement @reduce builtin for vector types
The builtin folds a Vector(N,T) into a scalar T using a specified
operator.

Closes #2698
2020-10-05 04:51:45 -04:00
Alexandros Naskos
23cd3b3331 Merge branch 'master' of https://github.com/ziglang/zig into add_some_frees 2020-10-04 10:39:26 +03:00
Andrew Kelley
2de53592a1 stage1: better value for builtin.link_mode
Now it is Dynamic unless -DZIG_STATIC=on is passed to cmake.

This partially addresses #6469.
2020-10-03 23:15:45 -07:00
Alexandros Naskos
82f0ede3ad Added some c_allocator.deallocate calls 2020-09-30 19:59:49 +03:00
Alexandros Naskos
cb5d290f33 Added a few ZigList deinit calls 2020-09-30 17:09:18 +03:00
Andrew Kelley
7067764ed3 Merge remote-tracking branch 'origin/master' into llvm11
The changes to install_files.h needed to put into src/libcxx.zig
2020-09-30 02:55:41 -07:00
Andrew Kelley
91a73a177b stage2: building mingw-w64 and COFF LDD linking
still TODO is the task of creating import .lib files for DLLs on the fly
both for -lfoo and for e.g. `extern "kernel32"`
2020-09-28 00:06:06 -07:00
Andrew Kelley
6af2990549 implement -femit-asm, -femit-docs, -femit-llvm-ir, etc
These CLI options are now forwarded to the stage1 backend.

We're not going to support the -mllvm CLI option any longer. As a
compromise, we unconditionally tell LLVM to output intel x86 syntax when
using -femit-asm.

Simplify stage1 logic; it no longer has the concept of an output
directory. --output-dir is no longer a valid CLI option. cmake uses
the `-femit-bin=[path]` option.

Note the changes to test/cli.zig. This breaks the CLI API that Godbolt
is using so we're going to want to open a PR to help them upgrade to the
new CLI for the upcoming Zig 0.7.0 release.
2020-09-26 01:47:27 -07:00
Andrew Kelley
528832bd3a rename src-self-hosted/ to src/ 2020-09-21 18:38:55 -07:00