1450 Commits

Author SHA1 Message Date
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
79671efd3a
fix inline loop behavior with variable result loc 2019-06-18 17:43:05 -04:00
Andrew Kelley
e27da17ff2
back to many behavioral tests passing 2019-06-18 17:07:27 -04:00
Andrew Kelley
77e0c53613
fix problem with inferred error set return result 2019-06-18 15:00:19 -04:00
Andrew Kelley
f90d17cc4d
fix bitcast 2019-06-18 14:44:25 -04:00
Andrew Kelley
077f9df15b
more miscellaneous fixes
when will it end
2019-06-18 14:30:17 -04:00
Andrew Kelley
9050a07540
when resolving slice types, might need to...
...resolve alignment if custom alignment is provided

fixes #2689
2019-06-18 11:31:05 -04:00
Andrew Kelley
8ed88280a6
Revert "fixes resolving aligment of child type in slice"
This reverts commit aa60d2a688c965dcccf8e2c42afe5c180daba8fc.

The copyright ownership of this 10 line patch is under dispute.
See #2701 for details. So I'll revert it and then fix it myself without
looking at this patch.
2019-06-18 11:18:53 -04:00
Andrew Kelley
fdc6e0af05
fix zero length array literal casted to slice 2019-06-18 10:49:21 -04:00
Andrew Kelley
e5a0414b05
misc fixes 2019-06-17 21:55:14 -04:00
Andrew Kelley
4e182c7e9e
inferred comptime array inits 2019-06-17 17:46:03 -04:00
Andrew Kelley
0568000844
fix function calls 2019-06-17 17:12:06 -04:00
Andrew Kelley
74250e434e
inferred comptime union inits 2019-06-17 16:27:45 -04: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
f4b8850002
fix type info crash on extern lib name 2019-06-16 14:14:57 -04:00
Jimmi HC
aa60d2a688 fixes resolving aligment of child type in slice 2019-06-16 00:03:43 -04:00
Andrew Kelley
9564c05cd5
better result location handling of inline loops 2019-06-15 19:19:13 -04:00
Andrew Kelley
6bf193af19
better result location semantics with optionals and return locations
somewhere along this branch, #1901 has been fixed.
2019-06-15 12:28:21 -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
7c074b8516
fix peer result locs with switch 2019-06-14 11:41:53 -04:00
Andrew Kelley
2ba29a1907
fix peer result location with error code and payload 2019-06-14 11:01:38 -04:00
Andrew Kelley
fdaca1b5f3
fix a couple more test regressions 2019-06-13 20:30:39 -04:00
Andrew Kelley
eaf74f4f96
fix bitcast packed struct to integer and back 2019-06-13 20:24:10 -04:00
Andrew Kelley
57347aacd7
fix atomic builtin functions 2019-06-13 20:01:25 -04:00
Andrew Kelley
24cfa3534f
allow comptime array literals casted to slices 2019-06-13 16:51:26 -04:00
Andrew Kelley
3cbe827464
fix behavior for nested array literals
new compile error for trying to cast runtime array literals to slices
2019-06-13 16:25:35 -04:00
Andrew Kelley
efb064449f
fix runtime initialize array elem and then implicit cast to slice 2019-06-13 13:31:15 -04:00
Andrew Kelley
b552e68c14
fix result loc implicit casting optionals and error unions
```zig
pub fn openHandle(handle: i32) File {
    return File{ .handle = handle };
}

pub fn getStdErr() anyerror!File {
    return openHandle(1);
}
```
2019-06-12 22:13:18 -04:00
Andrew Kelley
cdf14baa45
fix double nested peer result locations
```zig
export fn entry(x: bool) i32 {
    return if (x)
        if (x) a else b
    else
        if (x) c else d;
}
```
2019-06-12 21:46:04 -04:00
Andrew Kelley
0d62c92947
fix declref not writing to result loc
```zig
const a: i32 = 0;
const b: i32 = 1;
const c: i32 = 2;
const d: i32 = 3;

export fn entry(x: bool) i32 {
    return if (x)
        if (x)
            a
        else if (x)
            b
        else
            c
    else
        d;
}
```
2019-06-12 19:43:24 -04:00
Andrew Kelley
e6fa2ee706
fix nested peer result locs with no memory loc
```zig
export fn entry2(c: bool) i32 {
    return if (c)
        i32(0)
    else if (c)
        i32(1)
    else
        i32(2);
}
```

```llvm
define i32 @entry2(i1) #2 !dbg !35 {
Entry:
  %c = alloca i1, align 1
  store i1 %0, i1* %c, align 1
  call void @llvm.dbg.declare(metadata i1* %c, metadata !41, metadata !DIExpression()), !dbg !42
  %1 = load i1, i1* %c, align 1, !dbg !43
  br i1 %1, label %Then, label %Else, !dbg !43

Then:                                             ; preds = %Entry
  br label %EndIf3, !dbg !45

Else:                                             ; preds = %Entry
  %2 = load i1, i1* %c, align 1, !dbg !46
  br i1 %2, label %Then1, label %Else2, !dbg !46

Then1:                                            ; preds = %Else
  br label %EndIf, !dbg !47

Else2:                                            ; preds = %Else
  br label %EndIf, !dbg !47

EndIf:                                            ; preds = %Else2, %Then1
  %3 = phi i32 [ 1, %Then1 ], [ 2, %Else2 ], !dbg !47
  br label %EndIf3, !dbg !45

EndIf3:                                           ; preds = %EndIf, %Then
  %4 = phi i32 [ 0, %Then ], [ %3, %EndIf ], !dbg !45
  ret i32 %4, !dbg !48
}
```
2019-06-12 18:08:56 -04:00
Andrew Kelley
1526d89711
fix @bitCast with runtime scalar and dest result loc var 2019-06-12 15:02:46 -04:00
Andrew Kelley
35352e0f48
fix alignment problem with @bitCast result location 2019-06-12 13:49:57 -04:00
Andrew Kelley
278c7a2bc3
fix @bitCast regressions 2019-06-12 13:42:21 -04:00
Andrew Kelley
ce5d50e4ed
fix runtime if nested inside comptime if 2019-06-11 18:26:01 -04:00
Andrew Kelley
b3a4ec1bd2
fix returning scalar values
```zig
export fn entry1() i32 {
    return bar();
}
```

```llvm
define i32 @entry1() #2 !dbg !35 {
Entry:
  %0 = call fastcc i32 @bar(), !dbg !39
  ret i32 %0, !dbg !41
}
```
2019-06-11 16:04:04 -04:00
Andrew Kelley
e1d14e73b5
fix @bitCast semantics when there is no parent result loc 2019-06-11 15:44:06 -04:00
Andrew Kelley
0ac566892d
fix for loop index variable not in scope 2019-06-11 14:15:58 -04:00
Andrew Kelley
515092210f
fix not checking return value of resolving result 2019-06-11 13:48:53 -04:00
Andrew Kelley
1c2e889820
fix struct and array init when result casted to anyerror!?T
previous commit message is incorrect, it was only for
anyerror!T
2019-06-11 13:44:09 -04:00
Andrew Kelley
fc8d881240
fix struct and array init when result casted to anyerror!?T 2019-06-11 13:27:01 -04:00
Andrew Kelley
06f307ff77
fix implicit casting return value struct/arary init to optional 2019-06-11 12:19:57 -04:00
Andrew Kelley
a431a73dab
fixes for crashes and compile errors 2019-06-11 01:24:55 -04:00
Andrew Kelley
b053a65573
fix comptime variables 2019-06-11 00:36:03 -04:00
Andrew Kelley
7411a88d5f
fix comptime function calls 2019-06-11 00:27:10 -04:00
Andrew Kelley
d504318f2e
remove the final legacy stack allocation 2019-06-10 23:54:28 -04:00
Andrew Kelley
f6d4e2565e
use result loc for ref instruction 2019-06-10 23:51:43 -04:00
Andrew Kelley
a0427d29e4
fix peer result locations in the face of unreachable
```zig
export fn entry() void {
    var nothing: ?*i32 = null;
    var whatever = if (nothing) |x1| i32(1) else unreachable;
}
```

```llvm
define void @entry() #2 !dbg !35 {
Entry:
  %nothing = alloca i32*, align 8
  %whatever = alloca i32, align 4
  store i32* null, i32** %nothing, align 8, !dbg !45
  call void @llvm.dbg.declare(metadata i32** %nothing, metadata !39, metadata !DIExpression()), !dbg !45
  %0 = load i32*, i32** %nothing, align 8, !dbg !46
  %1 = icmp ne i32* %0, null, !dbg !46
  br i1 %1, label %OptionalThen, label %OptionalElse, !dbg !46

OptionalThen:                                     ; preds = %Entry
  call void @llvm.dbg.declare(metadata i32** %nothing, metadata !43, metadata !DIExpression()), !dbg !46
  store i32 1, i32* %whatever, align 4, !dbg !47
  br label %OptionalEndIf, !dbg !46

OptionalElse:                                     ; preds = %Entry
  tail call fastcc void @panic(%"[]u8"* @1, %builtin.StackTrace* null), !dbg !48
  unreachable, !dbg !48

OptionalEndIf:                                    ; preds = %OptionalThen
  call void @llvm.dbg.declare(metadata i32* %whatever, metadata !44, metadata !DIExpression()), !dbg !49
  ret void, !dbg !50
}
```
2019-06-10 23:25:43 -04:00