15570 Commits

Author SHA1 Message Date
Matthew Borkowski
2d7b55aa0a translate_c: prevent a while under an if from stealing the else 2021-10-19 13:48:09 -04:00
Matthew Borkowski
135cb529de astgen.zig: fix emitting wrong error unwrapping instructions in tryExpr 2021-10-19 13:44:48 -04:00
Sizhe Zhao
ec3ed92f48 src/link/C/zig.h: Fix indent 2021-10-19 13:43:32 -04:00
Andrew Kelley
bea447a637 stage2: fix coercion of error set to error union
When returning an error set or an error union from a function which has
an inferred error set, it populates the error names in addition to the
set of functions. This can have false negatives, meaning that after
checking the map of an unresolved error set, one must do full error set
resolution before emitting a compile error.
2021-10-18 15:45:11 -07:00
Andrew Kelley
75c8c4442d coff linking: honor the link_libunwind flag 2021-10-18 10:49:39 -07:00
Matthew Borkowski
79a3dfcfd8 astgen.zig: fix false positive in breakExpr's checking for store_to_block_ptr 2021-10-18 13:18:47 -04:00
Andrew Kelley
cde3dd365e
Merge pull request #9966 from nektro/stage2-hasfield
stage2: implement `@hasField`
2021-10-18 00:57:10 -04:00
Andrew Kelley
7b00bef6bf Sema: resolveTypeFields before accessing type fields 2021-10-17 21:53:59 -07:00
Meghan Denny
0ef2e2520a stage2: implement @hasField
struct and union are kept in stage1 because struct/unionFieldCount are returning zero
2021-10-17 21:42:22 -07:00
Meghan Denny
7d0a74456b alphebetize behavior tests 2021-10-17 21:42:22 -07:00
Andrew Kelley
40cbf525f7 stage2: implement coercion from null to C pointer 2021-10-17 19:10:49 -07:00
Andrew Kelley
e5dac0a0b3 stage2: implement @embedFile 2021-10-17 18:59:11 -07:00
Andrew Kelley
ad17108bdd
Merge pull request #9960 from Snektron/bit-not
Some not and vector stuff
2021-10-17 21:59:10 -04:00
Andrew Kelley
e9d1e5e533 stage2: LLVM backend: lower constant field/elem ptrs 2021-10-17 17:02:20 -07:00
Andrew Kelley
07691db3ae stage2: fix handling of error unions as return type
* LLVM backend: fix phi instruction not respecting `isByRef`
   - Also fix `is_non_null` not respecting `isByRef`
 * Type: implement abiSize for error unions
2021-10-17 15:36:12 -07:00
Andrew Kelley
6534f2ef4f stage2: implement error wrapping
* Sema: fix returned operands not coercing to the function return type
   in some cases.
   - When returning an error or an error union from a function with an
     inferred error set, it will now populate the inferred error set.
   - Implement error set coercion for the common case of inferred error
     set to inferred error set, without forcing a full resolution.
 * LLVM backend: update instruction lowering that handles error unions
   to respect `isByRef`.
   - Also implement `wrap_err_union_err`.
2021-10-17 14:55:32 -07:00
Max Hollmann
53b87fa78a Move compareFn from init to type constructor in PriorityQueue and PriorityDequeue.
This change significantly improves performance for simple compare functions and modifies
the API to be more consistent with e.g. `HashMap`.
2021-10-17 17:47:43 -04:00
Robin Voetter
15a0b30d8e ci: disable macos stage 2 tests 2021-10-17 22:46:36 +02:00
Jonathan Marler
22beaf5afc actually fix child process deadlock on windows
Looks like I forgot to remove windows from this workaround condition when I finished implementing the child process output collection on windows.
2021-10-17 16:07:51 -04:00
LemonBoy
51be575745 std: Fix endless loop in fmt impl
Apparently there's a stage1 bug that may sometimes lead to an endless
loop being generated when unrolling the fmt impl.

Closes #9961
2021-10-17 16:06:40 -04:00
Robin Voetter
d004ef2e5d stage2: make zirBoolNot return undefined when argument is undefined 2021-10-17 20:33:04 +02:00
Robin Voetter
fd838584bf stage2: vector constants 2021-10-17 20:33:04 +02:00
Robin Voetter
d193ba9843 stage2: array->vector coercion 2021-10-17 20:33:04 +02:00
Robin Voetter
9336a87452 stage2: bitNot 2021-10-17 20:33:04 +02:00
Robin Voetter
6a3659c4e0 big.int: 2s-complement binary wrapping not 2021-10-17 20:33:04 +02:00
Stephen Gregoratto
98a37dfb23 Linux: Update syscall numbers for 5.14 2021-10-17 14:22:47 -04:00
Andrew Kelley
127cd06ba1 stage2: add haveFieldTypes() assertions
This will help with contributions such as #9966.
2021-10-17 10:59:40 -07:00
Andrew Kelley
fdd11f6cee Sema: coercion from error sets to anyerror 2021-10-16 12:41:03 -07:00
Andrew Kelley
4d6d6977b0 stage2: fixes to extern variables
* Relax compile error for "unable to export type foo" to allow
   integers, structs, arrays, and floats. This will need to be further
   improved to do the same checks as we do for C ABI struct field types.
 * LLVM backend: fix extern variables
 * LLVM backend: implement AIR instruction `wrap_err_union_payload`
2021-10-16 12:26:06 -07:00
Andrew Kelley
82ec56e47e
Merge pull request #9954 from Snektron/shifts
Big int saturating left shift
2021-10-16 15:06:13 -04:00
Meghan Denny
6f30c8c098 elevate more passing tests 2021-10-16 15:04:48 -04:00
Robin Voetter
1e09157b53 big ints: Fix set(signed int minimum) panic 2021-10-16 11:32:05 +02:00
Robin Voetter
f6bf24b2f3 stage2: comptime saturating shl 2021-10-16 11:32:05 +02:00
Robin Voetter
efa4f76c8b big ints: Saturating left shift + tests 2021-10-16 11:32:05 +02:00
Meghan
1df926b24e stage2: @hasDecl is passing 2021-10-16 04:09:16 -04:00
Andrew Kelley
682cdeceaa stage2: optional comparison and 0-bit payloads
* Sema: implement peer type resolution for optionals and null.
 * Rename `Module.optionalType` to `Type.optional`.
 * LLVM backend: re-use anonymous values. This is especially useful when
   isByRef()=true because it means re-using the same generated LLVM globals.
 * LLVM backend: rework the implementation of is_null and is_non_null
   AIR instructions. Generate slightly better LLVM code, and also fix
   the behavior for optionals whose payload type is 0-bit.
 * LLVM backend: improve `cmp` AIR instruction lowering to support
   pointer-like optionals.
 * `Value`: implement support for equality-checking optionals.
2021-10-15 18:37:09 -07:00
Andrew Kelley
186126c2a4 stage2: make hasCodeGenBits() always true for pointers
* LLVM backend: The `alloc` AIR instruction as well as pointer
   constants which point to a 0-bit element type now call a common
   codepath to produce a `*const llvm.Value` which is a non-zero pointer
   with a bogus-but-properly-aligned address.
 * LLVM backend: improve the lowering of optional types.
 * Type: `hasCodeGenBits()` now returns `true` for pointers even when
   it returns `false` for their element types.

Effectively, #6706 is now implemented in stage2 but not stage1.
2021-10-15 17:17:59 -07:00
Andrew Kelley
0536c25578 std.os: another workaround for stage1 @minimum behavior
This is a companion commit to 0915d24e6b34b67d358c1309e9bc8516416f1008.
2021-10-15 14:43:57 -07:00
Andrew Kelley
0915d24e6b std.os: add workarounds for stage1 @minimum implementation 2021-10-15 11:46:47 -07:00
joachimschmidt557
01b3905688 stage2 AArch64: move codegen to separate file 2021-10-15 13:58:14 -04:00
Andy Fleming
6a9726e495
Adds tip about testing stdlib files to CONTRIBUTING.md (#9946)
* Adds tip about testing stdlib files

* Adds main-pkg-path arg for safer development
2021-10-15 13:56:57 -04:00
travisstaloch
16ac034a32
Sat shl neg rhs (#9949)
* saturating shl - check for negative rhs at comptime

- adds expected compile_errors case for negative rhs

* add expected compile error for sat shl assign
2021-10-15 13:56:27 -04:00
Miles Alan
411e9ca4ad
Fix bug where std.math.asinh64 doesn't respect signedness for negative values (#9940)
* std: Correct math.asinh64 to return correct signedness for negative values

* std: Add tests for negative values for math.asinh32 and math.asinh64
2021-10-15 13:55:40 -04:00
Sizhe Zhao
f3ab092f67
std.os.windows: Fix typo (#9951) 2021-10-15 14:44:05 +02:00
Andrew Kelley
cacd5366a6 stage2: LLVM backend: implement wrap_optional AIR
and move over some passing tests
2021-10-14 22:16:26 -07:00
Andrew Kelley
55eea3b045 stage2: implement @minimum and @maximum, including vectors
* std.os: take advantage of `@minimum`. It's probably time to
   deprecate `std.min` and `std.max`.
 * New AIR instructions: min and max
 * Introduce SIMD vector support to stage2
 * Add `@Type` support for vectors
 * Sema: add `checkSimdBinOp` which can be re-used for other arithmatic
   operators that want to support vectors.
 * Implement coercion from vectors to arrays.
   - In backends this is handled with bitcast for vector to array,
     however maybe we want to reduce the amount of branching by
     introducing an explicit AIR instruction for it in the future.
 * LLVM backend: implement lowering vector types
 * Sema: Implement `slice.ptr` at comptime
 * Value: improve `numberMin` and `numberMax` to support floats in
   addition to integers, and make them behave properly in the presence
   of NaN.
2021-10-14 21:17:30 -07:00
Andrew Kelley
8b88274781 stage2: improved union support
* `Module.Union.getFullyQualifiedName` returns a sentinel-terminated
   slice so that backends that need null-termination do not need an
   additional copy.
 * Module.Union: implement a `getLayout` function which returns
   information about ABI size and alignment so that the LLVM backend can
   properly lower union types into llvm types.
 * Sema: `resolveType` now returns `error.GenericPoison` rather than a
   Type with tag `generic_poison`. Callsites that want to allow that
   need to bypass this higher-level function.
 * Sema: implement coercion of enums and enum literals to unions.
 * Sema: fix comptime mutation of pointers to unions
 * LLVM backend: fully implement proper lowering of union types and
   values according to the union layout, and update the handling of AIR
   instructions that deal with unions to support union layouts.
 * LLVM backend: handle `decl_ref_mut`
   - Maybe this should be unreachable since comptime vars should be
     changed to be non-mutable when they go out of scope, but it's
     harmless for the LLVM backend to support lowering the value.
 * Type: fix `requiresComptime` for optionals, pointers, and some other
   types. This function is still wrong for structs, unions, and enums.
2021-10-14 17:44:46 -07:00
Andrew Kelley
ed5a5e2293 move behavior tests that are passing for stage2 2021-10-13 21:43:19 -07:00
Andrew Kelley
0d4a94f32f stage2: improve handling of 0-bit types and arrays
* Make `alloc` AIR instructions call `resolveTypeLayout`.
 * `Sema.zirResolveInferredAlloc` now calls `requireRuntimeBlock` in the
   case that it operates on a non-comptime instruction.
 * `Type.abiSize` and `Type.abiAlignment` now return 0 for `void`
 * Sema: implement `resolveTypeFields` for unions.
 * LLVM Backend: support `ptr_elem_ptr` when the element type is 0-bit.
 * Type: improve `abiAlignment` implementation for structs to properly
   handle fields with non-default alignment.
 * Value: implement hashing array, vector, and structs.
2021-10-13 21:20:38 -07:00
Andrew Kelley
b0f80ef0d5 stage2: remove use of builtin.stage2_arch workaround
The LLVM backend no longer needs this hack! However, the other backends
still do. So there are still some traces of this workaround in use for now.
2021-10-13 18:43:43 -07:00