Commit Graph

1721 Commits

Author SHA1 Message Date
LemonBoy
57f751a864 Adjust tests for AArch64 2019-09-21 11:39:50 +02:00
LemonBoy
75ec7e4e00 Fix generation of tail fields for packed struct 2019-09-21 11:39:43 +02:00
Sahnvour
74d0b5bf7c reject types of automatic container layout in packed unions 2019-09-20 13:25:32 -04:00
Andrew Kelley
c9a5a6b83a
add test case for already fixed bug
closes #3046
2019-09-20 13:19:29 -04:00
Timon Kruiper
3b4a6679a6 Fix comptime bitcast inside an expression 2019-09-20 13:13:26 -04:00
Andrew Kelley
005a54a853
fixups for @splat
* Fix codegen for splat - instead of giving vectors of length N
   to shufflevector for both of the operands, it gives vectors of length
   1. The mask vector is the only one that needs N elements.
 * Separate Splat into SplatSrc and SplatGen; the `len` is not needed
   once it gets to codegen since it is redundant with the result type.
 * Refactor compile error for wrong vector element type so that the
   compile error message is not duplicated in zig source code
 * Improve implementation to correctly handle comptime values such as
   undefined and lazy values.
 * Improve compile error for bad vector element type to point to the
   correct place.
 * Delete dead code.
 * Modify behavior test to use an array cast instead of vector element
   indexing since I'm merging this splat commit out-of-order from
   Shawn's patch set.
2019-09-19 10:58:12 -04:00
Shawn Landden
01577a3af4
@splat 2019-09-19 10:11:06 -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
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
stratact
a165cc0535 Get more of the tests passing for FreeBSD (#3197)
* Add missing <stdint.h> include for uint8_t type declaration

* Add needed FreeBSD check to link to libpthread

* Apply patch to enable more tests in the FreeBSD CI
2019-09-10 14:50:54 -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
Michael Dusan
8bd5681651 fix tests.addPkgTests to always run native target
- include native-target when native-target ∉ cross_targets

old behavior:

- do nothing when `-Dskip-non-native`
- never execute pkg tests for non-members of cross_targets
2019-09-10 10:10:14 -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
Michael Dusan
0d9a78a852 test-stack-traces: add FreeBSD 2019-09-09 00:25:21 -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
7d303ae861
runtime safety for noasync function calls
See #3157
2019-09-06 13:08:44 -04:00
Andrew Kelley
0a3c6dbda9
implement noasync function calls
See #3157
2019-09-05 21:55:32 -04:00
Timon Kruiper
ca70ca7e26 Add compiler error when negating invalid type 2019-09-05 15:27:50 -04:00
Andrew Kelley
2045b4d932
prefer result type casting to peer type resolution
See #2749
2019-09-05 14:56:52 -04:00
Timon Kruiper
866c253e0e
Add compile error when shifting amount is not an int type 2019-09-05 13:10:39 -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
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
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
aba67ecf44
rename test-compare-panic to test-stack-traces 2019-09-03 10:08:39 -04:00
Andrew Kelley
1fd24791a7
rename compare-panic to compare-stack-traces 2019-09-03 10:05:19 -04:00
Michael Dusan
a19e73d8ae
test: add compare-panic
`zig build test-compare-panic`

Create basic tests to compare panic output. The address field
is replaced by a symbolic constant and each expected output is
specific to os. Tests will only run for explicitly defined
platforms.

see also #2485
2019-09-03 09:59:43 -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