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 f2a5d0bf94897554e25e889dc1c6c4c7fc6c1217.
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
Luuk de Gram
f931c0638d
wasm: Implement errunion_payload_ptr_set
...
This also fixes `ret_ptr` where the pointee type is zero-sized.
2022-03-09 13:53:10 -07:00
Luuk de Gram
d01bfa032d
wasm: Preliminary fptrunc support
...
This implements the initial fptrunc instruction. For all other floating-point truncating,
a call to compiler-rt is required. (This also updates fpext to emit the same error).
2022-03-09 13:53:10 -07:00
Luuk de Gram
684b81f366
wasm: Implement fpext
...
This implements initial support for floating-point promotion for bitsizes <= 64
2022-03-09 13:53:10 -07:00
Luuk de Gram
557f396f61
wasm: Improve switch implementation
...
- Implement switching over booleans and pointers.
- Fix sparse-detection where the lowest value was never truly set
as it started at a non-zero number and the case was > 50.
- Fix indexing the jump table by ensuring it starts indexing from 0.
2022-03-09 13:53:10 -07:00
Andrew Kelley
b936fe0a58
Merge pull request #11101 from Vexu/stage2
...
Sema: handle noreturn result in condbr_inline
2022-03-09 15:07:00 -05:00
Veikka Tuominen
01b454f851
AstGen: ensure lableld block implicitly ends in a break
2022-03-09 17:12:40 +02:00
Veikka Tuominen
bb1fa0bdbd
Sema: handle noreturn result in condbr_inline
2022-03-09 17:07:25 +02:00
Andrew Kelley
0f0d27ce24
Sema: implement tuple fieldptr and fieldval
2022-03-09 01:19:29 -07:00
Andrew Kelley
bb73775d40
Sema: implement coercion of tuples to structs
2022-03-08 22:19:25 -07:00
Andrew Kelley
6f560c9909
Sema: implement comptime struct fields
2022-03-08 20:52:38 -07:00
Andrew Kelley
a91753219d
Merge pull request #11085 from ziglang/llvm-debug-info
...
stage2 LLVM debug info
2022-03-08 21:09:20 -05:00
Andrew Kelley
935d208ffb
Merge pull request #11090 from mitchellh/inferred-ty
...
stage2: correct comptime-known inferred alloc type, plus comptime array init sentinels
2022-03-08 20:56:00 -05:00
Andrew Kelley
fb4ad37e0b
LLVM: fix memory leak of debug type names
...
This required adjusting `Type.nameAlloc` to be used with a
general-purpose allocator and added `Type.nameAllocArena` for the arena
use case (avoids allocation sometimes).
2022-03-08 15:03:03 -07:00
Andrew Kelley
874b51d8d4
LLVM: add debug info for opaque, vector, and tuples
...
Also fix UAF of Type memory in the di_type_map.
2022-03-08 14:58:54 -07:00
Andrew Kelley
fa57335ec6
stage2: implement Type.getOwnerDecl for opaque types
2022-03-08 14:58:54 -07:00
Andrew Kelley
1046ead0cc
LLVM: no longer store args into alloca instructions
...
Previously, we did this so that we could insert a debug variable
declaration intrinsic on the alloca. But there is a dbg.value intrinsic
for declaring variables that are values.
2022-03-08 14:58:53 -07:00
Andrew Kelley
7cea8f063f
LLVM: add debug info for parameters
2022-03-08 14:58:53 -07:00
Andrew Kelley
ba566eed76
LLVM: fix not handling dbg_stmt relative line
...
Also make `namespaceToDebugScope` behave correctly for file-level
structs. Instead of being inside their own scope, they use the file
scope.
2022-03-08 14:58:53 -07:00
Andrew Kelley
3654ec8770
LLVM: add debug type lowering for ptr, slice, opaque, optional
...
also fix issue with memoization and recursiveness.
2022-03-08 14:58:53 -07:00
Andrew Kelley
40c0bdd385
LLVM: memoize debug types and add enum debug types
2022-03-08 14:58:53 -07:00
Andrew Kelley
0d24bc7da0
LLVM: add DISubprogram and DIType lowering; handle dbg_stmt
2022-03-08 14:58:53 -07:00
Andrew Kelley
627209253c
langref: fix a stray anyopaque that should be a void
2022-03-08 14:58:53 -07:00
Andrew Kelley
c6160fa3a5
LLVM: add compile unit to debug info
...
This commit also adds a bunch of bindings for debug info.
2022-03-08 14:58:53 -07:00
joachimschmidt557
95fc41b2b4
stage2 ARM: implement ret_load
2022-03-08 21:10:04 +01:00
Mitchell Hashimoto
ba62853d26
stage2: sentinel array init must add sentinel to array value
...
I didn't realize that the `array` value type has the sentinel on it.
2022-03-08 12:05:12 -08:00
Mitchell Hashimoto
cd32b11eb8
stage2: inferred alloc can use bitcast ty
...
The comment notes that we can't because of constness, but the recent
work by @Vexu lets us use the bitcast ty cause constness comes later.
The following tests pass from this:
```
test "A" {
const ary = [_:0]u8{42};
const ptr: [*:0]const u8 = &ary;
try expect(ptr[1] == 0);
}
test "B" {
comptime {
const ary = [_:0]u8{42};
const ptr: [*:0]const u8 = &ary;
try expect(ptr[1] == 0);
}
}
```
2022-03-08 12:04:51 -08:00