11169 Commits

Author SHA1 Message Date
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
Jakub Konka
0d2c25ca9d aarch64: use common implementation of genTypedValue 2023-03-03 18:46:08 +01:00
Andrew Kelley
2834b937f1 link: give executable bit to wasm executables sometimes
Give +x to the .wasm file if it is an executable and the OS is WASI.
Some systems may be configured to execute such binaries directly. Even
if that is not the case, it means we will get "exec format error" when
trying to run it rather than "access denied", and then can react to that
in the same way as trying to run an ELF file from a foreign CPU
architecture.

This is part of the strategy to unify RunStep and EmulatableRunStep.
2023-03-03 12:43:12 -05:00
Jakub Konka
c413ac100f codegen: refactor generating Int as immediate where appropriate 2023-03-03 18:40:16 +01:00
Jakub Konka
1024332adc arm: use common implementation of genTypedValue helper 2023-03-03 18:24:58 +01:00
Jakub Konka
c746cbc686 codegen: move gen logic for typed values, consts and decl ref to common codegen 2023-03-03 18:06:25 +01:00
Eckhart Köppen
6be5946ed8 sema: Place functions on AVR in flash addrspace
- Use .flash as the default address space for functions on AVR
- Return .flash as the address space for function pointers on AVR
  without explicit address space
2023-03-03 15:20:31 +02:00
Andrew Kelley
db8217f9a0 packages: avoid creating multiple modules with same build.zig
When there is a diamond dependency, reuse a *Module instead of creating
a redundant one using the same build.zig file. Otherwise, the compile
error "file exists in multiple modules" would occur.
2023-03-01 20:01:23 -05:00
Auguste Rame
25b83188d0
Add --build-runner zig build option (#14742) 2023-03-01 13:20:01 -05:00
John Schmidt
e41bc640c6 astgen: do not discard result location in for/while loops
If we use the discard result location any break with a value will be
ignored and not checked for usage.

Closes https://github.com/ziglang/zig/issues/14684.
2023-03-01 02:51:59 -05:00
Jacob Young
6bed45b873 codegen: fix test failures
Various backend were mismatching arg instructions and function args.
2023-02-27 16:30:15 -05:00
Jacob Young
a3529c2dea tools: implement more lldb pretty printers 2023-02-27 05:37:03 -05:00