aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
AgeCommit message (Collapse)Author
2023-06-15Sema: don't assume slice value is interned when loading from comptime pointermlugg
Resolves: #16030
2023-06-14test/behavior/generics.zig: remove outdated TODOzooster
2023-06-14Merge pull request #15726 from mlugg/feat/peer-type-resolution-but-betterAndrew Kelley
Sema: rewrite peer type resolution
2023-06-13Sema: rewrite peer type resolutionmlugg
The existing logic for peer type resolution was quite convoluted and buggy. This rewrite makes it much more resilient, readable, and extensible. The algorithm works by first iterating over the types to select a "strategy", then applying that strategy, possibly applying peer resolution recursively. Several new tests have been added to cover cases which the old logic did not correctly handle. Resolves: #15138 Resolves: #15644 Resolves: #15693 Resolves: #15709 Resolves: #15752
2023-06-13all: replace `comptime try` with `try comptime`Eric Joldasov
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13std.builtin: remove `TypeInfo` and `Type.FnArg` (deprecated in 0.10)Eric Joldasov
Followup to d3d24874c91054a70c706fed47278c81c9ce890a. Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13std.math: hard deprecate obsolete constants (soft deprecated in 0.10)Eric Joldasov
Followup to 5b8ac9821dd25c3e5282130b4d93d6c5b7debb08. Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
2023-06-13Sema: resolve union payload switch captures with peer type resolutionmlugg
This is a bit harder than it seems at first glance. Actually resolving the type is the easy part: the interesting thing is actually getting the capture value. We split this into three cases: * If all payload types are the same (as is required in status quo), we can just do what we already do: get the first field value. * If all payloads are in-memory coercible to the resolved type, we still fetch the first field, but we also emit a `bitcast` to convert to the resolved type. * Otherwise, we need to handle each case separately. We emit a nested `switch_br` which, for each possible case, gets the corresponding union field, and coerces it to the resolved type. As an optimization, the inner switch's 'else' prong is used for any peer which is in-memory coercible to the target type, and the bitcast approach described above is used. Pointer captures have the additional constraint that all payload types must be in-memory coercible to the resolved type. Resolves: #2812
2023-06-10wasm: address behavior test regressionsJacob Young
2023-06-10behavior: update for different inferred error set orderJacob Young
Error sets are no longer alphabetically sorted.
2023-06-10behavior: pass more tests on llvm againJacob Young
2023-06-10Sema: resolve peer vector types before comparisonmlugg
Resolves: #15732
2023-06-10AstGen: handle ref_table for paramsmlugg
This is kind of similar to 1a4b0d9. In this case, we need to handle ref_table when appending the body of param instructions. Resolves: #15952
2023-06-03Merge pull request #15579 from squeek502/mem-delimitersAndrew Kelley
Split `std.mem.split` and `tokenize` into `sequence`, `any`, and `scalar` versions
2023-06-03AstGen: handle ref_table for errdefer capturesmlugg
Resolves: #15861
2023-05-31enable passing behavior testsLuuk de Gram
2023-05-30Merge pull request #15905 from jacobly0/x86_64-hotfixJakub Konka
x86_64: hotfix for crash during in-memory coercion of large type
2023-05-29x86_64: hotfix for crash during in-memory coercion of large typeJacob Young
Unblocks #15768 Closes #15904
2023-05-29Prevent analysis of functions only referenced at comptimemlugg
The idea here is that there are two ways we can reference a function at runtime: * Through a direct call, i.e. where the function is comptime-known * Through a function pointer This means we can easily perform a form of rudimentary escape analysis on functions. If we ever see a `decl_ref` or `ref` of a function, we have a function pointer, which could "leak" into runtime code, so we emit the function; but for a plain `decl_val`, there's no need to. This change means that `comptime { _ = f; }` no longer forces a function to be emitted, which was used for some things (mainly tests). These use sites have been replaced with `_ = &f;`, which still triggers analysis of the function body, since you're taking a pointer to the function. Resolves: #6256 Resolves: #15353
2023-05-29Sema: return comptime_int if all args to @min/@max are comptime_intmlugg
Resolves: #15776
2023-05-29fix #15778: Binary operations on empty vectors crashEvin Yulo
2023-05-25disable test on C backendVeikka Tuominen
This test was previously incorrect and was not testing the intended instruction.
2023-05-25llvm: fix vector type in vector_store_elemVeikka Tuominen
Closes #15848
2023-05-24Sema: `@memcpy` convert src slice to many ptrVeikka Tuominen
Closes #15838
2023-05-24make `@boolToInt` always return a u1tison
Signed-off-by: tison <wander4096@gmail.com>
2023-05-20Merge pull request #15753 from Snektron/spirv-more-testsAndrew Kelley
spirv: make more tests pass
2023-05-20Merge pull request #15748 from alichraghi/ali-spirvVeikka Tuominen
spirv: lower get_union_tag
2023-05-20Merge pull request #15663 from Luukdegram/wasm-test-runnerLuuk de Gram
wasm: enable standard test runner
2023-05-20Zir: eliminate `field_call_bind` and `field_call_bind_named`mlugg
This commit removes the `field_call_bind` and `field_call_bind_named` ZIR instructions, replacing them with a `field_call` instruction which does the bind and call in one. `field_call_bind` is an unfortunate instruction. It's tied into one very specific usage pattern - its result can only be used as a callee. This means that it creates a value of a "pseudo-type" of sorts, `bound_fn` - this type used to exist in Zig, but now we just hide it from the user and have AstGen ensure it's only used in one way. This is quite silly - `Type` and `Value` should, as much as possible, reflect real Zig types and values. It makes sense to instead encode the `a.b()` syntax as its own ZIR instruction, so that's what we do here. This commit introduces a new instruction, `field_call`. It's like `call`, but rather than a callee ref, it contains a ref to the object pointer (`&a` in `a.b()`) and the string field name (`b`). This eliminates `bound_fn` from the language, and slightly decreases the size of generated ZIR - stats below. This commit does remove a few usages which used to be allowed: - `@field(a, "b")()` - `@call(.auto, a.b, .{})` - `@call(.auto, @field(a, "b"), .{})` These forms used to work just like `a.b()`, but are no longer allowed. I believe this is the correct choice for a few reasons: - `a.b()` is a purely *syntactic* form; for instance, `(a.b)()` is not valid. This means it is *not* inconsistent to not allow it in these cases; the special case here isn't "a field access as a callee", but rather this exact syntactic form. - The second argument to `@call` looks much more visually distinct from the callee in standard call syntax. To me, this makes it seem strange for that argument to not work like a normal expression in this context. - A more practical argument: it's confusing! `@field` and `@call` are used in very different contexts to standard function calls: the former normally hints at some comptime machinery, and the latter that you want more precise control over parts of a function call. In these contexts, you don't want implicit arguments adding extra confusion: you want to be very explicit about what you're doing. Lastly, some stats. I mentioned before that this change slightly reduces the size of ZIR - this is due to two instructions (`field_call_bind` then `call`) being replaced with one (`field_call`). Here are some numbers: +--------------+----------+----------+--------+ | File | Before | After | Change | +--------------+----------+----------+--------+ | Sema.zig | 4.72M | 4.53M | -4% | | AstGen.zig | 1.52M | 1.48M | -3% | | hash_map.zig | 283.9K | 276.2K | -3% | | math.zig | 312.6K | 305.3K | -2% | +--------------+----------+----------+--------+
2023-05-20spirv: ptr_elem_valRobin Voetter
Implements the ptr_elem_val air tag. Implementation is unified with ptr_elem_ptr.
2023-05-20spirv: ptr_subRobin Voetter
Implments the ptr_sub air tag. The code is unified with that of ptr_add.
2023-05-20spirv: customize module-scope asm testRobin Voetter
This test passes just fine, but the provided assembly is not valid for spir-v. This adds a custom assembly test and enables the test for spir-v
2023-05-20spirv: more passing testsRobin Voetter
2023-05-20spirv: pointer bitcastingRobin Voetter
2023-05-20spirv: ptr_addRobin Voetter
Implements the ptr_add air tag for spirv. The implementation for slices is probably wrong, but there seems to be no test for this...
2023-05-20spirv: dont use OpIAddCarryRobin Voetter
This instruction is not really working well in the LLVM SPIRV translator, as it is not implemented. This commit also intruces the constructStruct helper function to initialize structs at runtime. This is ALSO buggy in the translator, and we must work around OpCompositeConstruct not working when some of the constituents are runtime-known only. Some other improvements are made: - improved variable() so that it is more useful and no longer requires the address space. It always puts values in the Function address space, and returns a pointer to the Generic address space - adds a boolToInt utility function
2023-05-20spirv: use intInfo instead of arithmeticTypeInfo in airIntCastRobin Voetter
This ensures that we can also cast enums and error sets here. In the future this function will need to be changed to support composite and strange integers, but that is fine.
2023-05-20spirv: implement pointer comparison in for air cmpRobin Voetter
It turns out that the Khronos LLVM SPIRV translator does not support OpPtrEqual. Therefore, this instruction is emitted using a series of conversions. This commit breaks intToEnum, because enum was removed from the arithmetic type info. The enum should be converted to an int before this function is called.
2023-05-20spirv: lower get_union_tagAli Chraghi
2023-05-19wasm: fix `div_trunc` for floatsLuuk de Gram
For floats we would previously only do the division, but not the truncation for floats. This would result in incorrect values being returned.
2023-05-19wasm: support `memset` for elem abi size > 1Luuk de Gram
Previously we incorrectly assumed all memset's to have its element abi-size be 1 byte. This would set the region of memory incorrectly. We now have a more efficient loop, as well as support any element type by re-using the `store` function for each element and moving the pointer by 1 element.
2023-05-19wasm: implement `shl` for big integersLuuk de Gram
2023-05-19wasm: correctly use elem type when loweringLuuk de Gram
Previously when lowering a value of `elem_ptr` we would multiply the abisize of the parent type by the index, rather than the element type. This would result in an invalid pointer way beyond the correct pointer. We now also pass the current offset to each recursive call to ensure we do not miss inner offsets.
2023-05-18x86_64: implement saturating add/sub for weird typesJacob Young
2023-05-18codegen: emit global vector paddingJacob Young
2023-05-18x86_64: implement integer vector `@truncate`Jacob Young
2023-05-18x86_64: delete some incorrect codeJacob Young
2023-05-18x86_64: fix multi-limb compareJacob Young
2023-05-18x86_64: initialize array sentinelsJacob Young
2023-05-18x86_64: rewrite castsJacob Young