aboutsummaryrefslogtreecommitdiff
path: root/src/value.zig
AgeCommit message (Collapse)Author
2022-12-19value: remove `indexVectorlike`Veikka Tuominen
Vectors can represented in all the same values as arrays so this was never a valid shortcut.
2022-12-19value: use int tag type when querying for tag valueVeikka Tuominen
Closes #13757
2022-12-19behavior: disable failing testJacob Young
Also add an assert to catch this issue earlier. For future reference, the decl without a type and value is the string literal "GET".
2022-12-18Merge pull request #13930 from r00ster91/renamingsVeikka Tuominen
std.builtin: renamings
2022-12-17std.builtin: rename Type.UnionField and Type.StructField's field_type to typer00ster91
2022-12-15Sema: elide integer comparisons with guaranteed outcomesStevie Hryciw
2022-12-14Fix tautological big_int tests.IntegratedQuantum
2022-12-13remove `stack` option from `@call`Veikka Tuominen
2022-12-09Eliminate `BoundFn` type from the languageVeikka Tuominen
Closes #9484
2022-12-03Sema: fix comparisons between lazy and runtime valuesVeikka Tuominen
Closes #12498
2022-12-02Sema: add error for failed assumption about struct having runtime bitsVeikka Tuominen
2022-12-01Value: fix elemValueAdvanced for optional payloadsVeikka Tuominen
Closes #13707
2022-11-29stage2: fix crash on comptime lazy `@ctz` and `@clz`Andrew Kelley
2022-11-23Sema: implement tuple declarationsVeikka Tuominen
2022-11-22value: account for undef value for ptr in slice in hashUncoercedJakub Konka
2022-11-20Type: make `hasRuntimeBitsAdvanced` take `AbiAlignmentAdvancedStrat`Veikka Tuominen
I wasn't able to create a reduced test case for this but the reasoning can be seen in `abiAlignmentAdvancedUnion` where if `strat` was lazy `hasRuntimeBitsAdvanced` would be given `null` instead of `sema` which would cause eager evaluation when it is not valid or desired.
2022-11-18Sema: optimize compare comptime float with intkkHAIKE
2022-11-18run zig fmt on everything checked by CIStevie Hryciw
2022-11-13Sema: remove `block` and `src` parameters from `getBuiltin`Veikka Tuominen
These parameters are only ever needed when `std.builtin` is out of sync with the compiler in which case panicking is the only valid operation anyways. Removing them causes a domino effect of functions no longer needing a `src` and/or a `block` parameter resulting in handling compilation errors where they are actually meaningful becoming simpler.
2022-11-10Merge pull request #13074 from topolarity/stage2-optAndrew Kelley
stage2: Miscellaneous fixes to vector arithmetic and copy elision
2022-11-10Sema: avoid breaking hash contract when instantiating generic functionsJacob Young
* Add tagName to Value which behaves like @tagName. * Add hashUncoerced to Value as an alternative to hash when we want to produce the same hash for value that can coerce to each other. * Hash owner_decl instead of module_fn in Sema.instantiateGenericCall since Module.Decl.Index is not affected by ASLR like *Module.Fn was, and also because GenericCallAdapter.eql was already doing this. * Use Value.hashUncoerced in Sema.instantiateGenericCall because GenericCallAdapter.eql uses Value.eqlAdvanced to compare args, which ignores coersions. * Add revealed missing cases to Value.eqlAdvanced. Without these changes, we were breaking the hash contract for monomorphed_funcs, and were generating different hashes for values that compared equal. This resulted in a 0.2% chance when compiling self-hosted of producing a different output, which depended on fingerprint collisions of hashes that were affected by ASLR. Normally, the different hashes would have resulted in equal checks being skipped, but in the case of a fingerprint collision, the truth would be revealed and the compiler's behavior would diverge.
2022-11-10stage2: Rename `Value.compare` to `compareAll`, etc.Cody Tapscott
These functions have a very error-prone API. They are essentially `all(cmp(op, ...))` but that's not reflected in the name. This renames these functions to `compareAllAgainstZero...` etc. for clarity and fixes >20 locations where the predicate was incorrect. In the future, the scalar `compare` should probably be split off from the vector comparison. Rank-polymorphic programming is great, but a proper implementation in Zig would decouple comparison and reduction, which then needs a way to fuse ops at comptime.
2022-11-05stage2: address of threadlocal variable is not comptime knownVeikka Tuominen
Closes #13215
2022-10-28Merge pull request #13221 from topolarity/packed-memAndrew Kelley
Introduce `std.mem.readPackedInt` and improve bitcasting of packed memory layouts
2022-10-28Value: Add `@intCast` in `writeToPackedMemory` for 32-bit targetsCody Tapscott
2022-10-28stage2: Use mem.readPackedInt etc. for packed bitcastsCody Tapscott
Packed memory has a well-defined layout that doesn't require conversion from an integer to read from. Let's use it :-) This change means that for bitcasting to/from a packed value that is N layers deep, we no longer have to create N temporary big-ints and perform N copies. Other miscellaneous improvements: - Adds support for casting to packed enums and vectors - Fixes bitcasting to/from vectors outside of a packed struct - Adds a fast path for bitcasting <= u/i64 - Fixes bug when bitcasting f80 which would clear following fields This also changes the bitcast memory layout of exotic integers on big-endian systems to match what's empirically observed on our targets. Technically, this layout is not guaranteed by LLVM so we should probably ban bitcasts that reveal these padding bits, but for now this is an improvement.
2022-10-28value: properly hash `null_value` pointerVeikka Tuominen
Closes #13325
2022-10-27Sema: use `runtime_value` instead of creating allocsVeikka Tuominen
2022-10-21stage2: Fix usage of getError()Cody Tapscott
Despite the old doc-comment, this function cannot be valid for all types since it operates with only a value and Error (Union) types have overlapping Value representations with other Types.
2022-10-21Merge pull request #13219 from Vexu/stage2-fixesVeikka Tuominen
Stage2 bug fixes
2022-10-20Value: handle runtime_int in hashPtrVeikka Tuominen
Closes #12702
2022-10-18value: implement `Value.eqlAdvanced` on slicesJacob Young
* Support comparison between implicitly casted array pointer and slice. * Support comparison between slices with different value tags. Closes #12700
2022-10-18stage2: implement packedStuctToInt for more typesGethDW
2022-10-17tools: add lldb stage2 pretty printersJacob Young
* Fix untagged struct names in debug info for llvm. * Factor out common stage2 pretty printer data. * Add lldb version of stage2 pretty printers.
2022-10-13Sema: add float128IntPartToBigInt to fix compare comptime float with intkkHAIKE
2022-09-15Sema: handle comptime fields in field call bindVeikka Tuominen
Closes #12801
2022-09-15value: hash extern functionsVeikka Tuominen
Closes #12766
2022-09-02Sema: resolve lazy value before intToFloatVeikka Tuominen
Closes #12698
2022-08-24Merge pull request #12623 from Vexu/stage2-fixesAndrew Kelley
Stage2 fixes
2022-08-24stage2: handle `int_u64` in `elemValueAdvanced`Veikka Tuominen
Closes #12599
2022-08-22stage2+stage1: remove type parameter from bit builtinsVeikka Tuominen
Closes #12529 Closes #12511 Closes #6835
2022-08-17Sema: fix generics with struct literal coerced to tagged unionAndrew Kelley
The `Value.eql` function has to test for value equality *as-if* the lhs value parameter is coerced into the type of the rhs. For tagged unions, there was a problematic case when the lhs was an anonymous struct, because in such case the value is empty_struct_value and the type contains all the value information. But the only type available in the function was the rhs type. So the fix involved making `Value.eqlAdvanced` also accept the lhs type, and then enhancing the logic to handle the case of the `.anon_struct` tag. closes #12418 Tests run locally: * test-behavior * test-cases
2022-08-10stage2: fix crash with comptime vector reduceAndrew Kelley
2022-08-10stage2: Handle lazy values for the % operatorIsaac Freund
2022-07-31Merge pull request #12289 from Vexu/stage2Andrew Kelley
Stage2: reify functions + fixes
2022-07-30stage2: Fix AIR printingCody Tapscott
Packed structs never have comptime fields, and a slice might actually be backed by a variable, which we need to catch before iterating its elements.
2022-07-30Sema: implement `@Type` for functionsVeikka Tuominen
Closes #12280
2022-07-30stage2: fix hashing of struct valuesVeikka Tuominen
Closes #12279
2022-07-14Sema: fix coerce_result_ptr in case of inferred result typeAndrew Kelley
Previously, the logic for analyzing coerce_result_ptr would generate invalid bitcast instructions which did not include coercion logic, such as optional wrapping, resulting in miscompilations. Now, the logic of resolve_inferred_alloc goes back over all the placeholders inserted by coerce_result_ptr, and replaces them with logic doing the proper coercions. Closes #12045
2022-07-13stage2: fix comptime bitcast involving f80Andrew Kelley
* Sema: implement comptime bitcast of f80 with integer-like types bitwise rather than taking a round trip through memory layout. * Type: introduce `isAbiInt`. * Value: comptime memory write of f80 writes 0 bytes for padding instead of leaving the memory uninitialized. * Value: floatReadFromMemory has a more general implementation, checking the endianness rather than checking for specific architectures. This fixes behavior test failures occurring on MIPS.