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
76f5396077
@byteSwap on vectors
2019-09-18 16:49:14 -04:00
Andrew Kelley
2038f4d45a
rework the implementation
...
* update documentation
- move `@shuffle` to be sorted alphabetically
- remove mention of LLVM
- minor clarifications & rewording
* introduce ir_resolve_vector_elem_type to avoid duplicate compile
error message and duplicate vector element checking logic
* rework ir_analyze_shuffle_vector to solve various issues
* improve `@shuffle` to allow implicit cast of arrays
* the shuffle tests weren't being run
2019-09-18 16:15:19 -04:00
Shawn Landden
193604c837
stage1: add @shuffle() shufflevector support
...
I change the semantics of the mask operand, to make it a little more
flexible. There is no real danger in this because it is a compile-error
if you do it the LLVM way (and there is an appropiate error to tell you
this).
v2: avoid problems with double-free
2019-09-18 11:26:45 -04:00
Shawn Landden
74ce5e9e13
stage1: proper return type on vector comparisons
2019-09-18 10:36:10 -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
914ad1ec2e
fix peer result location with typed parent, ...
...
...runtime condition, comptime prongs.
closes #3244
2019-09-17 22:30:49 -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
0eddee449d
add behavior test for @enumToInt(enum(u1){x}.x)
...
closes #2737
2019-09-11 15:05:00 -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
Andrew Kelley
852679c369
fix a var decl in scope preventing for loop spills
2019-09-09 16:44:23 -04:00
Andrew Kelley
a3993465fe
Merge pull request #3200 from LemonBoy/eq-tagged-union
...
Allow comparison between union tag and enum literal
2019-09-09 16:17:45 -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
LemonBoy
4b1cd45472
Comptime folding of enum/union comparisons
2019-09-09 19:09:56 +02:00
LemonBoy
cc63760587
Allow comparison between union tag and enum literal
...
Closes #2810
2019-09-09 18:51:13 +02:00
Andrew Kelley
f7721ac37c
implement spilling when returning error union async function call
...
closes #3190
2019-09-09 12:15:39 -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
Andrew Kelley
2045b4d932
prefer result type casting to peer type resolution
...
See #2749
2019-09-05 14:56:52 -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
LemonBoy
0107b19124
Resolve lazy values when checking for definedness
...
Fixes #3154
2019-09-05 13:09:43 -04:00
Jonathan Marler
9a358d2d33
Add Array support to @Type
2019-09-05 13:08:45 -04:00
Timon Kruiper
e540e5b8ec
Implicit cast from enum literal to optional enum and implicit cast to payload of error union
2019-09-04 12:30:23 -04:00
Andrew Kelley
ac7703f65f
fixups and add documentation for @Type
2019-09-04 11:12:14 -04:00
Jonathan Marler
b728cb6d4e
Add @Type builtin
2019-09-03 22:50:29 -06:00
Andrew Kelley
a81e4351a2
Merge branch 'fixSegfault' of https://github.com/marler8997/zig into marler8997-fixSegfault
2019-09-03 18:15:01 -04:00
Andrew Kelley
be17a4b6c1
fix compiler crash in struct field pointers
...
when the llvm type has not been fully analyzed. This is a regression
from lazy values.
2019-09-03 14:51:34 -04:00
Andrew Kelley
4a5b0cde13
fix const result loc, runtime if cond, else unreachable
...
Closes #2791 . See that issue for more details; I documented the
debugging process quite thoroughly on this one.
2019-09-02 20:28:25 -04:00
Andrew Kelley
ab4cba14c8
fix recursive call of await @asyncCall with struct return type
2019-09-02 14:35:41 -04:00
Andrew Kelley
d291d3c8c0
fix using @typeOf on a generic function call
2019-09-02 13:07:44 -04:00
Andrew Kelley
0c4d47c6d5
add regression test for already fixed bug
...
closes #2692
2019-09-01 23:35:58 -04:00
Andrew Kelley
ec6f15b0f5
fix @typeOf an async function call of generic fn with error union type
2019-09-01 00:27:22 -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
d9fed5cdfd
align(@alignOf(T)) T does not force resolution of T
2019-08-30 14:53:44 -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
af90da1531
fix implicit cast from zero sized array ptr to slice
...
closes #1850
2019-08-28 12:16:52 -04:00
Andrew Kelley
7139eef4cf
implement lazy values for error union types
...
closes #3129
2019-08-28 11:17:20 -04:00
Andrew Kelley
47fcbfdc51
add regression test for already fixed bug
...
closes #3112
2019-08-27 17:39:06 -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
c1fd7ed6e2
add regression test for struct with optional list of self
...
closes #1735
2019-08-27 14:06:17 -04:00
Andrew Kelley
e1b258f39f
add regression test for bug fixed by lazy values
...
closes #624
2019-08-27 13:44:04 -04:00
Andrew Kelley
8fef23a525
add regression test for bug fixed by lazy values
...
closes #1310
2019-08-27 13:36:42 -04:00
Andrew Kelley
ffac0b02e7
implement and test struct field explicit alignment
2019-08-27 10:14:11 -04:00