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
Mitchell Hashimoto
55ccf4c7a8
stage2: elem vals of many pointers need not deref pointers
...
By the time zirElemVal is reached for a many pointer, a load has already
happened, making sure the operand is already dereferenced.
This makes `mem.sliceTo` now work.
2022-03-08 14:10:43 -05:00
Andrew Kelley
6ffa44554e
Merge pull request #11079 from Vexu/stage2
...
stage2: make references to const allocs const
2022-03-08 13:49:29 -05:00
Benjamin San Souci
e3c2cc1443
std.json: correctly handle sentinel terminated slices
2022-03-08 20:43:13 +02:00
Evan Haas
4b9fd57aa8
translate-c: use nested scope for comma operator in macros
...
Fixes #11040
2022-03-08 20:38:51 +02:00
Jonathan Marler
d805adddd6
deprecated TypeInfo in favor of Type
...
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2022-03-08 20:38:12 +02:00
Jakub Konka
404f5d6179
x64: pass more behavior/cast.zig tests
2022-03-08 10:56:54 +01:00
joachimschmidt557
3ea603c82a
stage2 ARM: implement ptr_add, ptr_sub for all element sizes
...
Also reduces slice_elem_val to ptr_add, simplifying the implementation
2022-03-08 10:54:08 +01:00
Veikka Tuominen
8f037db885
stage2: correct constness of allocs
2022-03-08 11:23:39 +02:00
Veikka Tuominen
1f4a097117
stage2: fix mem{set,cpy} for non comptime mutable pointers
2022-03-08 11:23:38 +02:00
Jakub Konka
ba17552b4e
dwarf: move all dwarf into standalone module
...
Hook up Elf and MachO linkers to the new solution.
2022-03-08 09:46:27 +01:00
Andrew Kelley
38c161afab
Sema: fix @hasDecl for simple enums
2022-03-07 13:54:25 -07:00
Andrew Kelley
c467f6693e
stage2: fix union layout returning non-zero for zero-sized tag
2022-03-07 13:36:58 -07:00