11180 Commits

Author SHA1 Message Date
Jakub Konka
292f91aef2 Handle .ah vs .spl register aliases 2023-03-11 20:05:49 +01:00
Jakub Konka
bc43cee775 Get more things passing 2023-03-11 20:05:49 +01:00
Jakub Konka
ea3b3e94ab x86_64: clean up call semantics in codegen 2023-03-11 20:05:49 +01:00
Jakub Konka
f14831ec73 x86_64: truncate immediates 2023-03-11 20:05:49 +01:00
Jakub Konka
817fb263b5 x86_64: downstream table-driven instruction encoder 2023-03-11 20:05:49 +01:00
Andrius Bentkus
4ea2f441df Module: retry ZIR cache file creation
There are no dir components, so you would think that this was
unreachable, however we have observed on macOS two processes racing to
do openat() with O_CREAT manifest in ENOENT.

closes #12138
2023-03-11 06:20:51 -05:00
Luuk de Gram
904f414e7e
Merge pull request #14869 from Luukdegram/wasm-linker
wasm-linker: refactor virtual addresses
2023-03-10 16:48:30 +01:00
mlugg
023753b469 Sema: correctly detect use of undefined within slices in @Type
Resolves: #14712
2023-03-10 12:18:06 +02:00
Luuk de Gram
0ee9a52507
wasm-linker: remove synthetic segments & atoms 2023-03-10 06:20:10 +01:00
antlilja
b445bbfea2 Add ability to import dependencies from build.zig 2023-03-09 22:38:14 -05:00
Luuk de Gram
87738cad86
wasm-linker: store symbol's virtual address
For data symbols we will now store its virtual address. This means
we do no longer have to calculate it each time a relocation asks
for the address. This is now done for all data symbols only once
rather than every single relocation for that symbol.

This now also allows us directly store the virtual address of synthetic
symbols without having to create an atom for them. This means we also
don't need to have a "synthetic" segment any longer and do not emit
the synthetic symbols such as __heap_end and __heap_base into the final
binary.
2023-03-09 19:14:17 +01:00
mlugg
6d7fb8f19c Sema: check type of comptime try operand
Resolves: #14693
2023-03-09 02:02:19 +02:00
John Schmidt
ecc0108cea astgen: fill result location with void value if no other value
With this change, `break` and `break :blk` will fill the result location
with `.void_value`, ensuring that the value will be type checked.
The same will happen for a for loop that contains no `break`s in it's body.

Closes https://github.com/ziglang/zig/issues/14686.
2023-03-08 16:35:53 +02:00
Frank Denis
fea14c78d1
wasm-linker: emit build_id section (#14820)
The Build ID is a value that uniquely identifies a build.

It is intended to capture the "meaning" or inputs of the build,
and is usually associated with debug info.

Reference: https://github.com/WebAssembly/tool-conventions/blob/main/BuildId.md
2023-03-08 13:50:06 +00:00
Jacob Young
e3cf9d1650 Module: rewrite zir caching logic
Multiple processes can sit waiting for the exclusive lock at the same
time, so we want to recheck whether it needs to be updated whenever
we get an exclusive lock.

This also fixes a race condition between one process truncating the
cache file and another process reading it without atomic locking.
2023-03-08 00:00:52 -05:00
Jacob Young
77d06012c2 CBE: implement unsigned big int div and mod 2023-03-07 03:03:35 -05:00
r00ster91
6218e40046 Zir: fix outdated comment 2023-03-06 18:18:52 -05:00
r00ster91
70cbe5ac7c AstGen: remove unnecessary pubs
I think it helps when you know that something is entirely
self-contained, which AstGen is. The only function public is `generate`.
2023-03-06 18:18:52 -05:00
jim price
6ab04b5941 std.os: Allow write functions to return INVAL errors
In Linux when interacting with the virtual file system when writing
in invalid value to a file the OS will return errno 22 (INVAL).

Instead of triggering an unreachable, this change now returns a
newly introduced error.InvalidArgument.
2023-03-06 15:59:18 -05:00
Andrew Kelley
c839c180ef stage2: add zig_backend to ZIR cache namespace 2023-03-05 17:23:09 -07:00
Andrew Kelley
48e72960a4 llvm: fix lowering of @trap
It needed an unreachable instruction after it.
2023-03-05 17:23:09 -07:00
Andrew Kelley
2641feb9b9
Merge pull request #14789 from jacobly0/ditype
llvm: fix use after free with pointers to optional slices
2023-03-05 16:32:51 -05:00
r00ster91
f1ae688d37 AstGen: ensure certain builtin functions return void
Fixes #14779

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-03-05 23:01:17 +02:00
jiacai2050
29c56a8aa7 fix package redeclaration when cache is not found 2023-03-05 14:59:34 -05:00
Andrew Kelley
7b01af2bfd
Merge pull request #14745 from jacobly0/bigint
CBE: add support for integers larger than 128 bits (and apparently vectors too)
2023-03-05 14:48:06 -05:00
jim price
a63134a4a5 std.os: Add DeviceBusy as a possible write error
In Linux when writing to various files in the virtual file system,
for example /sys/fs/cgroup, if you write an invalid value to a file
you'll get errno 16.

This change allows for these specific cases to be caught instead of
being lumped together in UnexpectedError.
2023-03-05 17:56:44 +02:00
Jacob Young
1efd36cd5c CBE: fix reduce of emulated integers 2023-03-05 06:32:55 -05:00
Jacob Young
33fa25ba44 CBE: ensure uniqueness of more internal identifiers 2023-03-05 02:59:02 -05:00
Jacob Young
0b0298aff2 CBE: implement select and shuffle 2023-03-05 02:59:02 -05:00
Jacob Young
aac4707902 CBE: implement splat 2023-03-05 02:59:02 -05:00
Jacob Young
ba69ee488b CBE: implement vector truncate 2023-03-05 02:59:02 -05:00
Jacob Young
8f6da78fb1 CBE: implement vector element pointers 2023-03-05 02:59:02 -05: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
b2e9c0d0ff Sema: fix cmp_vector type 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
Andrew Kelley
e7f128c205
Merge pull request #14782 from r00ster91/trap
add `@trap` builtin
2023-03-04 16:20:31 -05:00
r00ster91
010596c930 AstGen: compile-error on primitive value export
Fixes #14778

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2023-03-04 22:52:57 +02:00
Jacob Young
2cf27c5718 llvm: fix incorrectly annotated DIType
Closes #14715
Closes #14783
2023-03-04 13:52:47 -07:00
r00ster91
4eb3f50fcf Wasm @breakpoint: emit unreachable
This should improve the developer debugging experience.
2023-03-04 12:08:23 +01: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
Jakub Konka
18e6d1e819
Merge pull request #14781 from ziglang/codegen-cleanup
codegen: move common logic for generating typed values from each native backend into codegen.zig
2023-03-04 03:38:12 +01:00
r00ster91
d6bd00e855 Zir: move set_cold from Inst.Tag to Inst.Extended
If I could mark a builtin function as cold, I would mark @setCold as cold.
We have run out of `Zir.Inst.Tag`s so I had to move a tag from Zir.Inst.Tag to
Zir.Inst.Extended. This is because a new noreturn builtin will be added and
noreturn builtins cannot be part of Inst.Tag:
```
/// `noreturn` instructions may not go here; they must be part of the main `Tag` enum.
pub const Extended = enum(u16) {
```

Here's another reason I went for @setCold:
```
$ git grep setRuntimeSafety | wc -l
322
$ git grep setCold | wc -l
79
$ git grep setEvalBranchQuota | wc -l
82
```

This also simply removes @setCold from Autodoc and the docs frontend because
as far as I could understand it, builtins represented using Zir extended
instructions are not yet supported because I couldn't find
@setStackAlign or @setFloatMode there, either.
2023-03-03 21:16:21 +01:00
Jakub Konka
dc709fbf48 codegen: rename GenerateSymbolError to CodeGenError 2023-03-03 18:56:57 +01:00
Jakub Konka
d23472747e elf: fully zero out symbol when appending to freelist 2023-03-03 18:53:47 +01:00
Jakub Konka
f6eeb6c8ce sparc64: use common implementation of genTypedValue 2023-03-03 18:53:30 +01:00
Jakub Konka
5b3ea49806 riscv64: use common implementation of genTypedValue 2023-03-03 18:53:13 +01:00