11624 Commits

Author SHA1 Message Date
Jakub Konka
ac434fd8cc x86_64: avoid inline for-loops when scanning the encodings table 2023-03-12 22:06:22 +01:00
mlugg
a8bd55e085 translate-c: translate extern unknown-length arrays using @extern
Resolves: #14743
2023-03-12 19:07:06 +02:00
mlugg
c93e0d8618 Sema: @extern fixes
* There was an edge case where the arena could be destroyed twice on
  error: once from the arena itself and once from the decl destruction.

* The type of the created decl was incorrect (it should have been the
  pointer child type), but it's not required anyway, so it's now just
  initialized to anyopaque (which more accurately reflects what's
  actually at that memory, since e.g. [*]T may correspond to nothing).

* A runtime bitcast of the pointer was performed, meaning @extern didn't
  work at comptime. This is unnecessary: the decl_ref can just be
  initialized with the correct pointer type.
2023-03-12 18:55:23 +02:00
mlugg
948926c513 Sema: improve error message when calling non-member function as method
Resolves: #14880
2023-03-12 18:47:02 +02:00
Jakub Konka
955e394792 x86_64: fix 32bit build issues in the encoder 2023-03-12 08:47:23 +01:00
Jakub Konka
707a74655b x86_64: downstream encoder/assembler tests 2023-03-12 08:41:44 +01:00
Jakub Konka
433558a92f x86_64: clean up 2023-03-11 20:05:50 +01:00
Jakub Konka
f279ccb807 x86_64: rename asmNone to asmOpOnly 2023-03-11 20:05:50 +01:00
Jakub Konka
fb38e3d6b2 x86_64: simplify immediate handling at MIR level 2023-03-11 20:05:50 +01:00
Jakub Konka
0a8b5c20aa x86_64: add wrapper for .jcc with relocation 2023-03-11 20:05:50 +01:00
Jakub Konka
c9a153c797 x86_64: add .dead pseudo-instruction to mark an unused MIR instruction 2023-03-11 20:05:50 +01:00
Jakub Konka
621fc36b55 x86_64: add wrapper for .jmp_reloc 2023-03-11 20:05:50 +01:00
Jakub Konka
21630ea17f x86_64: apply couple of tweaks and pass behavior tests 2023-03-11 20:05:50 +01:00
Jakub Konka
6e1da36503 x86_64: PtrSize.fromSize() should take into account nonexact sizes too 2023-03-11 20:05:50 +01:00
Jakub Konka
e34e7d5ad1 x86_64: add missing decodings for .movsx 2023-03-11 20:05:50 +01:00
Jakub Konka
fe1fab4a8e x86_64: fix CALL emits for ELF and Plan9 2023-03-11 20:05:49 +01:00
Jakub Konka
d0e7212539 x86_64: finish rolling out all MIR assembly helpers 2023-03-11 20:05:49 +01:00
Jakub Konka
022b308d6a x86_64: start converting MI references 2023-03-11 20:05:49 +01:00
Jakub Konka
4af8313f36 x86_64: plug up all RM/MR references 2023-03-11 20:05:49 +01:00
Jakub Konka
32708dd6e2 x86_64: add RM and MR helpers to codegen 2023-03-11 20:05:49 +01:00
Jakub Konka
9658ab6766 x86_64: handle all instructions without introducing Memory operand 2023-03-11 20:05:49 +01:00
Jakub Konka
1bde522c2c x86_64: add helper for Jcc instruction 2023-03-11 20:05:49 +01:00
Jakub Konka
7221cd8ec9 x86_64: add helpers for CMOVcc and SETcc at the MIR level 2023-03-11 20:05:49 +01:00
Jakub Konka
f61a70e812 x86_64: handle encoding and decoding Imm64 unsigned 2023-03-11 20:05:49 +01:00
Jakub Konka
aa8fda799e x86_64: split up assemble() into more declarative single-purpose helpers 2023-03-11 20:05:49 +01:00
Jakub Konka
6e882d730b x86_64: introduce assemble() helper which encodes/decodes into MIR -> Instruction 2023-03-11 20:05:49 +01:00
Jakub Konka
5b37701028 x86_64: refactor immediate selection logic 2023-03-11 20:05:49 +01:00
Jakub Konka
219c1261a5 x86_64: all behavior tests passing 2023-03-11 20:05:49 +01:00
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
0606f0aa55 sema: fix result ptr coercion array -> vector
Previously this worked for array to vector where the element type
matched exactly (e.g `[4]u8` to `@Vector(4, u8)`) since that is
performed with a simple `.bitcast` operation, but now it also works for
types where the array is coercible to the vector type (e.g `[4]u8` to
`@Vector(4, u16)`).
2023-03-09 00:55:33 +01:00
John Schmidt
505e720421 sema: add peer type resolution for vectors
This is consistent with how coercion for vectors work. So now you can do
this:

```
var a: @Vector(2, u16) = .{1, 2};
var b: @Vector(2, u8) = .{2, 1};
const c = @min(a, b);
```

where previously you had to cast explicitly:

```
var a: @Vector(2, u16) = .{1, 2};
var b: @Vector(2, u8) = .{2, 1};
var c: @Vector(2, u16) = b;
const c = @min(a, c);
```
2023-03-09 00:55:17 +01: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
Krzysztof Wolicki Der Teufel
27d2848e00 autodoc: Add struct to tryResolveRefPath
fix rendering of fieldRef in exprName
2023-03-07 00:32:26 +01: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