Michael Dusan
7a2b0cc9c4
fix stack escape in add_source_file()
2019-06-29 13:19:39 -04:00
Andrew Kelley
3085d29af8
Merge remote-tracking branch 'origin/master' into copy-elision-3
2019-06-26 14:44:01 -04:00
Andrew Kelley
c61e0a078c
fix union init with void payload
...
all std lib tests passing now
2019-06-25 11:31:38 -04:00
Shawn Landden
71e014caec
stage1: add @sin @cos @exp @exp2 @ln @log2 @log10 @fabs @floor @ceil @trunc @round
...
and expand @sqrt
This revealed that the accuracy of ln is not as good as the current algorithm in
musl and glibc, and should be ported again.
v2: actually include tests
v3: fix reversal of in and out arguments on f128M_sqrt()
add test for @sqrt on comptime_float
do not include @nearbyInt() until it works on all targets.
2019-06-22 14:34:34 -05:00
Andrew Kelley
ff6d563b04
fix implicit cast to optional to error union to return result loc
2019-06-21 17:49:54 -04:00
Shawn Landden
ebde2ff899
stage1: update fn_key_eql() for @mulAdd() on vectors
2019-06-21 08:44:20 -05:00
Andrew Kelley
b588a803bf
fix comptime modification of const struct field
2019-06-19 14:35:59 -04:00
Shawn Landden
fce2d2d18b
stage1: add support for @mulAdd fused-multiply-add for floats and vectors of floats
...
Not all of the softfloat library is being built....
Vector support is very buggy at the moment, but should work when the bugs are fixed.
(as I had the same code working with another vector function, that hasn't been merged yet).
2019-06-19 12:07:02 -05:00
Andrew Kelley
b025193de5
inferred comptime values rather than elided scopes
...
because of this example:
```zig
export fn entry(b: bool) usize {
var runtime = [1]i32{3};
comptime var i: usize = 0;
inline while (i < 2) : (i += 1) {
const result = if (i == 0) [1]i32{2} else runtime;
}
comptime {
return i;
}
}
```
The problem is that the concept of "resetting" a result location,
introduced in the previous commit, cannot handle elision scopes.
This concept is inherently broken with inline loops.
2019-06-17 13:31:19 -04:00
Andrew Kelley
60025a3704
Merge remote-tracking branch 'origin/master' into copy-elision-3
2019-06-15 10:34:04 -04:00
Andrew Kelley
f8f054b354
fix @export for arrays not respecting the symbol name
...
Previously, the symbol name parameter of `@export` would be ignored for
variables, and the variable name would be used for the symbol name.
Now it works as expected.
See #2679
2019-06-14 17:23:24 -04:00
Andrew Kelley
42ea2d0d1c
fix @export for arrays and allow sections on extern variables
...
previously `@export` for an array would panic with a TODO message.
now it will do the export. However, it uses the variable's name
rather than the name passed to `@export`. Issue #2679 remains open
for that problem.
2019-06-14 15:28:52 -04:00
Andrew Kelley
7411a88d5f
fix comptime function calls
2019-06-11 00:27:10 -04:00
Andrew Kelley
3a4b749c8a
Merge remote-tracking branch 'origin/master' into copy-elision-3
2019-06-09 19:44:01 -04:00
Andrew Kelley
b735764898
different array literal syntax when inferring the size
...
old syntax: []i32{1, 2, 3}
new syntax: [_]i32{1, 2, 3}
closes #1797
2019-06-09 19:26:32 -04:00
Andrew Kelley
771e88951a
result location mechanism for struct initialization
...
```zig
export fn entry() void {
const static = Foo{
.x = 9,
.bar = Bar{ .y = 10 },
};
const runtime = foo(true);
}
fn foo(c: bool) Foo {
return Foo{
.x = 12,
.bar = if (c) bar1() else bar2(),
};
}
fn bar1() Bar {
return Bar{ .y = 34 };
}
fn bar2() Bar {
return Bar{ .y = 56 };
}
```
```llvm
@0 = internal unnamed_addr constant %Foo { i32 9, %Bar { i32 10 } }, align 4
@1 = internal unnamed_addr constant %Bar { i32 34 }, align 4
@2 = internal unnamed_addr constant %Bar { i32 56 }, align 4
define void @entry() #2 !dbg !35 {
Entry:
%runtime = alloca %Foo, align 4
call void @llvm.dbg.declare(metadata %Foo* @0, metadata !39 , metadata !DIExpression()), !dbg !50
call fastcc void @foo(%Foo* sret %runtime, i1 true), !dbg !51
call void @llvm.dbg.declare(metadata %Foo* %runtime, metadata !49 , metadata !DIExpression()), !dbg !52
ret void, !dbg !53
}
define internal fastcc void @foo(%Foo* nonnull sret, i1) unnamed_addr #2 !dbg !54 {
Entry:
%c = alloca i1, align 1
store i1 %1, i1* %c, align 1
call void @llvm.dbg.declare(metadata i1* %c, metadata !60 , metadata !DIExpression()), !dbg !61
%2 = getelementptr inbounds %Foo, %Foo* %0, i32 0, i32 0, !dbg !62
store i32 12, i32* %2, align 4, !dbg !62
%3 = getelementptr inbounds %Foo, %Foo* %0, i32 0, i32 1, !dbg !64
%4 = load i1, i1* %c, align 1, !dbg !65
br i1 %4, label %Then, label %Else, !dbg !65
Then: ; preds = %Entry
call fastcc void @bar1(%Bar* sret %3), !dbg !66
br label %EndIf, !dbg !64
Else: ; preds = %Entry
call fastcc void @bar2(%Bar* sret %3), !dbg !67
br label %EndIf, !dbg !64
EndIf: ; preds = %Else, %Then
ret void, !dbg !68
}
define internal fastcc void @bar1(%Bar* nonnull sret) unnamed_addr #2 !dbg !69 {
Entry:
%1 = bitcast %Bar* %0 to i8*, !dbg !73
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %1, i8* align 4 bitcast (%Bar* @1 to i8*), i64 4, i1 false), !dbg !73
ret void, !dbg !73
}
define internal fastcc void @bar2(%Bar* nonnull sret) unnamed_addr #2 !dbg !75 {
Entry:
%1 = bitcast %Bar* %0 to i8*, !dbg !76
call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %1, i8* align 4 bitcast (%Bar* @2 to i8*), i64 4, i1 false), !dbg !76
ret void, !dbg !76
}
!39 = !DILocalVariable(name: "static", scope: !40 , file: !5 , line: 2, type: !41 )
!49 = !DILocalVariable(name: "runtime", scope: !40 , file: !5 , line: 6, type: !41 )
```
2019-06-08 18:51:31 -04:00
Andrew Kelley
52eb347188
hook up result locs for try
2019-06-08 01:16:19 -04:00
LemonBoy
80cd142c96
Propagate DIFlags to LLVM
2019-06-04 09:05:33 +02:00
Andrew Kelley
ccce3d8526
no-copy semantics for function forwarding
...
```zig
fn foo() Foo {
return bar();
}
```
```llvm
define internal fastcc void @foo(%Foo* nonnull sret) unnamed_addr #2 !dbg !48 {
Entry:
call fastcc void @bar(%Foo* sret %0), !dbg !52
ret void, !dbg !54
}
```
2019-05-31 01:36:57 -04:00
Andrew Kelley
78f32259da
default struct field initialization expressions
...
closes #485
2019-05-30 15:46:11 -04:00
Andrew Kelley
1ab0ac3ea2
cleanups for windows subsystem in builtin.zig
2019-05-29 16:55:02 -04:00
Andrew Kelley
1ccbd1fb67
use works on unions and enums in addition to structs
2019-05-29 16:31:49 -04:00
Andrew Kelley
9891c4f30d
Merge branch 'use-struct-pt2' of https://github.com/LemonBoy/zig into LemonBoy-use-struct-pt2
2019-05-29 15:48:49 -04:00
LemonBoy
528c151a55
Reject undefined as type
...
Make analyze_type_expr behave like ir_resolve_type when the user tries
to use `undefined` as a type.
Closes #2436
2019-05-28 18:02:57 -04:00
LemonBoy
048169cbea
Avoid a crash when there are no namespace components
...
Fixes #2500
2019-05-28 17:49:37 -04:00
emekoi
3f302594b8
respect subsystem flag in all cases
2019-05-27 22:15:33 -04:00
LemonBoy
86b3007b94
Reject slices in use expressions
...
Co-Authored-By: emekoi <emekankurumeh@outlook.com>
2019-05-24 13:20:44 +02:00
LemonBoy
f67ca20655
Make use work with arbitrary structs
2019-05-21 17:07:40 +02:00
LemonBoy
b660134a18
Use the correct scope for use
...
use expressions outside the top-level scope now work as intended.
2019-05-19 00:32:49 -04:00
LemonBoy
d210628c91
Amend the error messages
2019-05-11 21:29:55 +02:00
LemonBoy
b05e8d46ec
Change the enum value allocation strategy
2019-05-11 21:29:53 +02:00
LemonBoy
655794f44f
amend type_is_valid_extern_enum_tag
2019-05-11 21:29:00 +02:00
LemonBoy
c766f3f9ca
Support signed types as enum tags
2019-05-11 21:28:58 +02:00
LemonBoy
917bd4192d
Validate enum tag for extern enum
...
The C specification mandates the enum to be compatible with signed char,
signed int or unsigned int.
2019-05-11 21:27:58 +02:00
Andrew Kelley
010963ce43
stage1: make some asserts print source location
2019-05-09 14:52:06 -04:00
Andrew Kelley
c82acdbb9e
clean up test output
...
After 4df2f3d74f test names have the word "test" in them so the
redundant word is removed from test runner. Also move the prefix/suffix
to where it logically belongs in the fully qualified symbol name.
2019-04-26 15:10:13 -04:00
rylmovuk
4df2f3d74f
Change symbol name of tests in codegen
...
Tests now have the symbol name of the format `test "<name>"` in order
to be more easily distinguished from functions with similar names.
See issue #2267 .
2019-04-26 14:23:56 -04:00
Andrew Kelley
976080462c
translate-c: a little closer to self-hosted implementation
2019-04-25 00:06:54 -04:00
Shawn Landden
8ef7f6febb
remove Shebang (#!) support
...
Closes: #2165
2019-04-24 23:34:19 -04:00
Michael Dusan
611d4bc6a1
stage1: const_values_equal support tagged union
2019-04-16 13:55:23 -04:00
Andrew Kelley
68d7e4a1b6
better handle quota of setEvalBranchQuota
...
Now that c58b80203443dcbf8b737ebdaa1f17fb20c77711 has removed
the "top of the comptime stack" requirement, the branch quota
can be modified somewhere other than the top of the comptime stack.
This means that the quota of a parent IrExecutable has to be
modifiable by an instruction in the child.
Closes #2261
2019-04-13 16:55:59 -04:00
Andrew Kelley
025a1475c4
emit better debug info for enums
...
fixes llvm assertion when building for windows
2019-04-02 19:40:33 -04:00
Andrew Kelley
6a7b75b73c
fix LLVM assertion failures
2019-04-02 19:09:25 -04:00
Andrew Kelley
15bd4aa54f
fix setting union body twice
2019-04-02 18:43:25 -04:00
Andrew Kelley
e9dc504141
avoid tripping assertion for setting struct body twice
2019-04-02 18:31:19 -04:00
Andrew Kelley
d577dde636
passing all tests
2019-04-02 18:31:19 -04:00
Andrew Kelley
9780fd59f0
put the alignment hack in for unions too. fixes std tests
2019-04-02 18:31:19 -04:00
Andrew Kelley
cb0241fe44
behavior tests passing again
2019-04-02 18:31:19 -04:00
Andrew Kelley
4c38a8cce1
more regression fixes. empty test passes again
2019-04-02 18:31:19 -04:00
Andrew Kelley
5aee17e888
regression fixes and fix packed struct abi size
2019-04-02 18:31:19 -04:00