Commit Graph

1054 Commits

Author SHA1 Message Date
Andrew Kelley
2c681d7ba1 add behavior test for float widening f16 to f128
it's disabled on aarch64, see #3282
2019-09-21 14:22:23 -04:00
Andrew Kelley
f3a7c346dd Merge pull request #3278 from LemonBoy/struct-gen
A few steps towards AArch64 & ARM passing the behavior tests
2019-09-21 13:46:13 -04:00
LemonBoy
75ec7e4e00 Fix generation of tail fields for packed struct 2019-09-21 11:39:43 +02:00
Andrew Kelley
3377044ebe Merge pull request #3183 from LemonBoy/fix-3128
Don't forget to resolve the pointee type
2019-09-20 18:01:42 -04:00
Sahnvour
74d0b5bf7c reject types of automatic container layout in packed unions 2019-09-20 13:25:32 -04:00
Andrew Kelley
380c8ec2c9 implement runtime @byteSwap and other fixups
* update docs for `@byteSwap`.
 * fix hash & eql functions for ZigLLVMFnIdBswap not updated to
   include vector len. this was causing incorrect bswap function
   being called in unrelated code
 * fix `@byteSwap` behavior tests only testing comptime and not
   runtime operations
 * implement runtime `@byteSwap`
 * fix incorrect logic in ir_render_vector_to_array and
   ir_render_array_to_vector with regards to whether or not to bitcast
 * `@byteSwap` accepts an array operand which it will cast to vector
 * simplify `@byteSwap` semantic analysis code and various fixes
2019-09-19 00:59:04 -04:00
Shawn Landden
0e3ca4c63e Fix array->vector and vector->array for many types. Allow vector of bool.
Vectors do not have the same packing as arrays, and just bitcasting
is not the correct way to convert them.
2019-09-18 09:52:58 -04:00
Andrew Kelley
c6e77f248d fix tripping llvm assert
```
Assertion `!isa<DIType>(Scope) && "shouldn't
make a namespace scope for a type"
```

We've had this problem and solved it before; see #579.
2019-09-16 14:31:41 -04:00
LemonBoy
eb7d36ae0d Make single-element enum default to u0
* Allow comptime_int as explicit enum tag type

Closes #2997
2019-09-13 15:13:10 -04:00
Andrew Kelley
c9b2210fcf async function calls re-use frame buffers
See #3069
2019-09-10 22:59:00 -04:00
LemonBoy
8b5cb8df99 Don't forget to resolve the pointee type
Fixes #3128
2019-09-10 19:07:04 +02:00
Andrew Kelley
0489d06c24 make the std lib support event-based I/O
also add -fstack-report
2019-09-10 10:26:52 -04:00
LemonBoy
8fbae77770 Force LLVM to generate byte-aligned packed unions
Sometimes the frontend and LLVM would disagree on the ABI alignment of a
packed union. Solve the problem by telling LLVM we're gonna manage the
struct layout by ourselves.

Closes #3184
2019-09-10 10:07:32 -04:00
Sahnvour
a06f84fcc6 forbid opaque types in function return types 2019-09-10 10:11:49 -04:00
Andrew Kelley
852679c369 fix a var decl in scope preventing for loop spills 2019-09-09 16:44:23 -04:00
Andrew Kelley
f50bfb94b5 fix bad LLVM IR when for target expr needs to be spilled
Also reduce the size of ZigVar in memory by making the name
a `const char *` rather than a `Buf`.
2019-09-09 15:59:16 -04:00
Andrew Kelley
229323e13a fix suspensions inside for loops generating invalid LLVM IR
closes #3076
2019-09-07 17:37:17 -04:00
Andrew Kelley
9a18db8a80 properly spill expressions with async function calls 2019-09-07 00:27:45 -04:00
Andrew Kelley
d1a98ccff4 implement spills when expressions used across suspend points
closes #3077
2019-09-07 00:13:12 -04:00
Andrew Kelley
9ca8d9e21a fix await used in an expression generating bad LLVM 2019-09-07 00:13:12 -04:00
Andrew Kelley
0a3c6dbda9 implement noasync function calls
See #3157
2019-09-05 21:55:32 -04:00
LemonBoy
8e3c56b912 Always resolve the struct field types
Packed structs used to skip the zero-sized types and trip some
assertions that expected the type reference not to be null.

Fixes #3143
2019-09-05 13:07:04 -04:00
Michael Dusan
fe153ad2a4 stage1 enhance IR print
- print fn name in pass1
- replace scalar with enum IrPass for clarity
2019-09-05 13:06:10 -04:00
LemonBoy
fabf45f5fc Add the noinline keyword for function declarations 2019-09-05 13:04:58 -04:00
Andrew Kelley
77a5f888be emit a compile error if a test becomes async
See #3117
2019-09-03 22:09:47 -04:00
Sahnvour
ce14c543d1 error message and test for alignment of variables of zero-bit types 2019-09-03 21:14:40 -04:00
Andrew Kelley
a81e4351a2 Merge branch 'fixSegfault' of https://github.com/marler8997/zig into marler8997-fixSegfault 2019-09-03 18:15:01 -04:00
Michael Dusan
1f99899408 stage1 enhance IR print
- pass2 now prints missing instructions in a trailing fashion
- instruction struct name added to print as column 2
2019-08-31 22:42:58 -04:00
Andrew Kelley
5c3a9a1a3e improvements to @asyncCall
* `await @asyncCall` generates better code. See #3065
 * `@asyncCall` works with a real `@Frame(func)` in addition to
   a byte slice. Closes #3072
 * `@asyncCall` allows passing `{}` (a void value) as the result
   pointer, which uses the result location inside the frame.
   Closes #3068
 * support `await @asyncCall` on a non-async function. This is in
   preparation for safe recursion (#1006).
2019-08-31 18:50:16 -04:00
Andrew Kelley
a223063923 @typeOf now guarantees no runtime side effects
related: #1627
2019-08-31 11:00:31 -04:00
Andrew Kelley
6ab8b2aab4 support recursive async and non-async functions
which heap allocate their own frames

related: #1006
2019-08-30 20:06:02 -04:00
Andrew Kelley
e9a4bcbcc6 fix regressions 2019-08-29 22:44:07 -04:00
Andrew Kelley
03910925f0 await does not force async if callee is blocking
closes #3067
2019-08-29 21:51:37 -04:00
Andrew Kelley
0512beca9d comparing against zero participates in lazy values 2019-08-29 14:46:22 -04:00
Andrew Kelley
d9f0446b1f make @sizeOf lazy 2019-08-29 12:43:56 -04:00
Andrew Kelley
94bbb46ca6 fix not fully resolving debug info for structs causing llvm error 2019-08-29 10:29:48 -04:00
Andrew Kelley
7139eef4cf implement lazy values for error union types
closes #3129
2019-08-28 11:17:20 -04:00
Andrew Kelley
f4519c520a support self-referential struct through a slice of optional
by making optionals even more lazy

closes #1805
2019-08-27 16:55:58 -04:00
Andrew Kelley
428a2fdedd better handle struct depends on itself via optional field
closes #1995
2019-08-27 13:59:18 -04:00
Andrew Kelley
d9ed55f017 fix not properly casting align values
and add check for alignment specified on enum fields
2019-08-27 12:54:50 -04:00
Andrew Kelley
7d34e55a71 add a TODO compile error for union field alignment syntax
See #3125
2019-08-27 10:45:28 -04:00
Andrew Kelley
ffac0b02e7 implement and test struct field explicit alignment 2019-08-27 10:14:11 -04:00
Andrew Kelley
db50cf7049 fix more compile error regressions 2019-08-26 22:38:45 -04:00
Andrew Kelley
bad4b040cc miscellaneous fixes regarding compile errors 2019-08-26 18:35:36 -04:00
Andrew Kelley
d316f70450 fix regression on struct field with undefined type 2019-08-26 14:01:59 -04:00
Andrew Kelley
73a7747a9c fix some compile error regressions 2019-08-26 12:43:36 -04:00
Andrew Kelley
6569bfc85e fix some std lib dependency loops 2019-08-26 11:23:25 -04:00
Andrew Kelley
e1a4bcbdfd fix dependency loop errors with zig build 2019-08-26 10:43:07 -04:00
Andrew Kelley
ede0c22a67 make @alignOf lazily evaluate the target type
this case works now:

```zig
const Foo = struct {
    field: Bar(@alignOf(*Foo)),
};
fn Bar(comptime alignment: u29) type {
    return struct {
        field: *align(alignment) Foo,
    };
}
```
2019-08-26 10:03:30 -04:00
Andrew Kelley
720302a640 fix resolution detection of pointer types 2019-08-25 21:28:16 -04:00