Commit Graph

17444 Commits

Author SHA1 Message Date
Andrew Kelley
f6b479b81d LLVM: use hasRuntimeBitsIgnoreComptime instead of hasRuntimeBits
LLVM codegen doesn't care whether types are comptime or not. Comptime
types aren't supposed to make it to codegen anyway.
2022-03-11 22:48:35 -07:00
Andrew Kelley
98c950827f std.math: remove redundant namespace in test names
related: #7923
2022-03-11 22:47:45 -07:00
Andrew Kelley
0f3e849719 std.ArrayList: use variable for local mutable state
stage1 has the wrong semantics here
2022-03-11 22:47:24 -07:00
Andrew Kelley
491e3ba6b1 LLVM: fix debug info for pointers to void 2022-03-11 21:00:07 -07:00
Andrew Kelley
60d6037f23 Sema: fix inline/comptime function calls with inferred errors 2022-03-11 20:44:10 -07:00
Andrew Kelley
55ba335e0f Sema: fix resolution of inferred error sets
Introduce `Module.ensureFuncBodyAnalyzed` and corresponding `Sema`
function. This mirrors `ensureDeclAnalyzed` except also waits until the
function body has been semantically analyzed, meaning that inferred
error sets will have been populated.

Resolving error sets can now emit a "unable to resolve inferred error
set" error instead of producing an incorrect error set type. Resolving
error sets now calls `ensureFuncBodyAnalyzed`. Closes #11046.

`coerceInMemoryAllowedErrorSets` now does a lot more work to avoid
resolving an inferred error set if possible. Same with
`wrapErrorUnionSet`.

Inferred error set types no longer check the `func` field to determine if
they are equal. That was incorrect because an inline or comptime function
call produces a unique error set which has the same `*Module.Fn` value for
this field. Instead we use the `*Module.Fn.InferredErrorSet` pointers to
test equality of inferred error sets.
2022-03-11 19:38:07 -07:00
Andrew Kelley
2ee3cc453c stage2: remove SPDX license header comments
These were missed in d29871977f.
2022-03-11 19:38:07 -07:00
Andrew Kelley
6f986298c6
Merge pull request #11125 from jmc-88/cbe
CBE: promote an already passing test, and add implementation for clz, ctz for integers
2022-03-11 20:15:13 -05:00
Daniele Cocca
226fcd7c70 CBE: implement clz, ctz for ints <= 128 bits 2022-03-11 23:12:15 +00:00
Mitchell Hashimoto
fca51c81bc stage2: is_non_error always returns comptime true for empty error set 2022-03-11 17:16:34 -05:00
Mitchell Hashimoto
797f4db227 stage2: Array len field should be a usize not comptime_int 2022-03-11 17:15:36 -05:00
Daniele Cocca
6dcfbfbfb2 CBE: mark union_with_members as passing 2022-03-11 20:53:14 +00:00
Andrew Kelley
79b169c5a5
Merge pull request #11122 from mitchellh/anon-has-field
stage2: @hasField for anon structs
2022-03-11 15:01:51 -05:00
Andrew Kelley
a2517117e7 Sema: make @hasField support tuples too 2022-03-11 12:59:20 -07:00
Mitchell Hashimoto
6a9c9afbae stage2: @hasField for anon structs 2022-03-11 12:51:21 -07:00
Andrew Kelley
86a98b172b std.os: disable failing fnctl file locking test
See #11074
2022-03-11 12:49:53 -07:00
Andrew Kelley
4c1cc4d8d9
Merge pull request #11120 from Vexu/stage2
Stage2: make std.rand tests pass
2022-03-11 13:48:28 -05:00
Joachim Schmidt
5fbae9cd6f
Merge pull request #11121 from joachimschmidt557/stage2-arm
stage2 ARM: implement caller-preserved registers
2022-03-11 17:43:36 +01:00
Veikka Tuominen
03b8206f27 Sema: make check for whether call should be memoized more thorough 2022-03-11 16:56:33 +02:00
joachimschmidt557
4590e980f7
stage2 ARM: implement caller-saved registers 2022-03-11 14:12:11 +01:00
joachimschmidt557
06058ed6f3
stage2 regalloc: replace Register.allocIndex with generic indexOfReg
* callee_preserved_regs and other ABI-specific information have been
moved to the respective abi.zig files
2022-03-11 13:29:16 +01:00
Veikka Tuominen
01cd4119b0 Sema: implement @shuffle at comptime and for differing lengths 2022-03-11 14:25:15 +02:00
Veikka Tuominen
cba68090a6 stage2: implement @shuffle at runtime 2022-03-11 13:12:32 +02:00
Veikka Tuominen
db42624170 Sema: enable shl and bitwise for vectors at runtime 2022-03-11 13:06:22 +02:00
Veikka Tuominen
98a5998d83 Sema: improve detection of generic parameters 2022-03-11 11:25:45 +02:00
Andrew Kelley
078037ab9b stage2: passing threadlocal tests for x86_64-linux
* use the real start code for LLVM backend with x86_64-linux
   - there is still a check for zig_backend after initializing the TLS
     area to skip some stuff.
 * introduce new AIR instructions and implement them for the LLVM
   backend. They are the same as `call` except with a modifier.
   - call_always_tail
   - call_never_tail
   - call_never_inline
 * LLVM backend calls hasRuntimeBitsIgnoringComptime in more places to
   avoid unnecessarily depending on comptimeOnly being resolved for some
   types.
 * LLVM backend: remove duplicate code for setting linkage and value
   name. The canonical place for this is in `updateDeclExports`.
 * LLVM backend: do some assembly template massaging to make `%%`
   rendered as `%`. More hacks will be needed to make inline assembly
   catch up with stage1.
2022-03-11 00:04:42 -07:00
Andrew Kelley
b28b3f6f7b stage2: fix comptime element load of undef array 2022-03-10 22:57:13 -07:00
Andrew Kelley
273da9efd9 AstGen: structInitExpr and arrayInitExpr avoid crash
when an inferred alloc is passed as the result pointer of a block.
2022-03-10 17:52:18 -07:00
Andrew Kelley
a30d283981 AstGen: lower anon struct inits differently
This is a companion commit to f2a5d0bf94.
What that one did for tuples, this one does for anonymous structs.
2022-03-10 17:52:18 -07:00
Andrew Kelley
b642fa24a6 stage2: implement integer pointer constants 2022-03-10 17:52:18 -07:00
Jakub Konka
b0dc61fae2 macos: add mach_* syscalls for process mgmt 2022-03-10 22:39:04 +01:00
Andrew Kelley
96f614d374
Merge pull request #11098 from mitchellh/error-merge-eql
stage2: error set type equality, error and error union value equality
2022-03-10 16:22:20 -05:00
Andrew Kelley
9f163310f2 stage2: improve Type.eql and Type.hash for error sets
* Reduce branching in Type.eql and Type.hash for error sets.
 * `Type.eql` uses element-wise bytes comparison since it can rely on
   the error sets being pre-sorted.
 * Avoid unnecessarily skipping tests that are passing.
2022-03-10 14:21:37 -07:00
Mitchell Hashimoto
569870ca41 stage2: error_set_merged type equality
This implements type equality for error sets. This is done
through element-wise error set comparison.

Inferred error sets are always distinct types and other error sets are
always sorted. See #11022.
2022-03-10 14:20:16 -07:00
Andrew Kelley
0b82c02945
Merge pull request #11113 from Vexu/stage2
stage2: if generic function evaluates to another generic function call it inline
2022-03-10 15:10:51 -05:00
Marc Tiehuis
8bab1b405f math: fix big.int div, gcd and bitAnd edge-cases
Fixes #10932.
2022-03-10 13:56:07 -05:00
Andrew Kelley
6e49ba77f3 std: add sort method to ArrayHashMap and MultiArrayList
This also adds `std.sort.sortContext` and
`std.sort.insertionSortContext` which are more advanced methods that
allow overriding the `swap` method. The former calls the latter for now
because reworking the main sort implementation is a big task that can be
done later without any changes to the API.
2022-03-10 13:13:17 -05:00
Veikka Tuominen
f9e4344bb5 Sema: implement zirStructInit is_ref=true union 2022-03-10 20:00:07 +02:00
Veikka Tuominen
673fafc231 stage2 llvm: implement lowerParentPtr for int_{u,i}64 2022-03-10 19:52:03 +02:00
Veikka Tuominen
e0fb0770d1 Sema: if generic function evaluates to another generic function call it inline
```zig
fn foo(a: anytype, b: @TypeOf(a)) void { _ = b; }
test {
    // foo evaluates to `fn (type) void` and must be called inline
    foo(u32, u32);
}
```
2022-03-10 13:04:55 +02:00
Veikka Tuominen
b9f521b402 Sema: add coercion from [:x]T to [*:x]T 2022-03-10 12:02:31 +02:00
Andrew Kelley
f736cde397 Sema: implement pointer to tuple to pointer to array coercion
This involved an LLVM backend fix for the aggregate_init instruction.
2022-03-09 18:49:37 -07:00
Meghan
017d3864de
std: fix false positive for zig.isValidId with empty string (#11104)
* std: fix false positive for `zig.isValidId` with empty string, fixes #11099
* std: add zig.isValidId tests
2022-03-09 19:38:47 -05:00
Andrew Kelley
f32a77b30d Sema: implement pointer-to-tuple coercion to slice and struct 2022-03-09 17:33:01 -07:00
Andrew Kelley
3b6e8fa59e Sema: fix crash with @sizeOf on unions 2022-03-09 16:02:42 -07:00
Andrew Kelley
fd85cfe154 std.mem: remove redundant namespaces in test names
related: #7923
2022-03-09 15:44:08 -07:00
Andrew Kelley
83bb3d1ad6 Sema: fix generic fn instantiation with anytype
When the anytype parameter had only one-possible-value
(e.g. `void`), it would create a mismatch in the function type and the
function call. Now the function type and the callsite both omit the
one-possible-value anytype parameter in instantiated generic functions.
2022-03-09 15:35:13 -07:00
Andrew Kelley
2aa4a32097
Merge pull request #11105 from Luukdegram/wasm-misc
stage2: wasm - miscellaneous improvements
2022-03-09 16:03:20 -05:00
Luuk de Gram
90f08a69aa wasm: Enable passing behavior tests
This also adds some float-related instructions to MIR/Emit
2022-03-09 13:53:20 -07:00
Luuk de Gram
3ea113e008 wasm: Implement field_parent_ptr 2022-03-09 13:53:10 -07:00