273 Commits

Author SHA1 Message Date
Jakub Konka
8c233687b4 stage2: partially implement intcast on x86_64
* fix violating encoding invariant for memory encoding
* enable some cast tests for x86_64 and arm
2022-01-18 13:18:59 +01:00
Andrew Kelley
4d05f2ae5f remove zig_is_stage2 from @import("builtin")
Instead use the standarized option for communicating the
zig compiler backend at comptime, which is `zig_backend`. This was
introduced in commit 1c24ef0d0b09a12a1fe98056f2fc04de78a82df3.
2022-01-17 21:55:49 -07:00
Luuk de Gram
e7b7088056
wasm: Implement float_to_int
- This implements the float_to_int AIR instruction.
- Lowering a decl_ref to a slice was previously assumed to contain a pointer
to a slice, rather than an array. This is now fixed, making `@src()` work as well.
- Some preliminary work on 128bit integers have been done to find out what needs to be done
to implement 128bit arithmetic.
2022-01-10 21:01:00 +01:00
Meghan
c08b190c69
lint: duplicate import (#10519) 2022-01-07 00:06:06 -05:00
Andrew Kelley
b4d6e85a33 Sema: implement peer type resolution of signed and unsigned ints
This allows stage2 to build more of compiler-rt.

I also changed `-%` to `-` for comptime ints in the div and mul
implementations of compiler-rt. This is clearer code and also happens to
work around a bug in stage2.
2022-01-02 14:11:37 -07:00
Robin Voetter
2b589d71fb stage2: move some tests which are now passing 2021-11-22 04:36:57 +01:00
Andrew Kelley
09588c795c stage2: LLVM backend: memset to 0xaa for undefined stores
Also support `one` and `int_big_positive` tags for const pointers.
2021-11-16 17:46:39 -07:00
Drew P
68fe391de0 typo 2021-11-16 16:51:31 -07:00
Drew P
30ed91b7b9 fix tests failing on stage2 release modes due to setRuntimeSafety not being recognized 2021-11-16 16:51:31 -07:00
drew
0249344a47 cast -> cast_llvm, cast_c -> cast (doesn't work on LLVM backend) 2021-11-16 16:51:31 -07:00
drew
9bf1681990 C backend: basic big ints, fix airPtrToInt, array references, pointer arithmetic UB with NULL, implement airPtrElemPtr/Val, fix redundant indirection/references with arrays
-add additional test cases that were found to be passing
-add basic int128 test cases which previously did not pass but weren't covered
-most test cases in cast.zig now pass
-i128/u128 or smaller int constants can now be rendered
-unsigned int constants are now always suffixed with 'u' to prevent random compile errors
-pointers with a val tag of 'zero' now just emit a 0 constant which coerces to the pointer type and fixes some warnings with ordered comparisons
-pointers with a val tag of 'one' are now casted back to the pointer type
-support pointers with a u64 val
-fix bug where rendering an array's type will emit more indirection than is needed
-render uint128_t/int128_t manually when needed
-implement ptr_add/sub AIR handlers manually so they manually cast to int types which avoids UB if the result or ptr operand is NULL
-implement airPtrElemVal/Ptr
-airAlloc for arrays will not allocate a ref as the local for the array is already a reference/pointer to the array itself
-fix airPtrToInt by casting to the int type
2021-11-16 16:51:31 -07:00
Zen1th
0d7359ca9b
stage2: Implement Sema.floatToInt (#10097) 2021-11-09 18:52:30 -05:00
Andrew Kelley
c6b3d06535 Sema: improved C pointers and casting
* C pointer types always have allowzero set to true but they omit the
   word allowzero when printed.
 * Implement coercion from C pointers to other pointers.
 * Implement in-memory coercion for slices and pointer-like optionals.
 * Make slicing a C pointer drop the allowzero bit.
 * Value representation for pointer-like optionals is now allowed to use
   pointer tag values in addition to the `opt_payload` tag.
2021-10-26 13:46:27 -07:00
Andrew Kelley
ed7328119f Sema: implement coercion from pointers to *c_void 2021-10-25 11:34:23 -07:00
Andrew Kelley
895aea0b63 Sema: fix type checking of @intToFloat operands
There was a typo and they were backwards.
2021-10-21 23:01:05 -07:00
Andrew Kelley
0a6851cc6d stage2: implement comptime loads through casted pointers 2021-10-21 22:56:11 -07:00
Andrew Kelley
c4df9bf56f AstGen: fix while and for with unreachable bodies
Companion commit to 61a53a587558ff1fe1b0ec98bb424022885edccf.

This commit also moves over a bunch of behavior test cases to the
passing-for-stage2 section.
2021-10-02 20:15:03 -07:00
Andrew Kelley
6eecc4af99 stage2 llvm backend: implement const inttoptr 2021-08-12 10:48:54 -07:00
Jacob G-W
9fffffb07b fix code broken from previous commit 2021-06-21 17:03:03 -07:00
Jacob G-W
641ecc260f std, src, doc, test: remove unused variables 2021-06-21 17:03:03 -07:00
Veikka Tuominen
e63ff4f1c1 add ast-check flag to zig fmt, fix found bugs 2021-06-14 00:16:40 +03:00
Andrew Kelley
5619ce2406 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * doc/langref.html.in
 * lib/std/enums.zig
 * lib/std/fmt.zig
 * lib/std/hash/auto_hash.zig
 * lib/std/math.zig
 * lib/std/mem.zig
 * lib/std/meta.zig
 * test/behavior/alignof.zig
 * test/behavior/bitcast.zig
 * test/behavior/bugs/1421.zig
 * test/behavior/cast.zig
 * test/behavior/ptrcast.zig
 * test/behavior/type_info.zig
 * test/behavior/vector.zig

Master branch added `try` to a bunch of testing function calls, and some
lines also had changed how to refer to the native architecture and other
`@import("builtin")` stuff.
2021-05-08 14:45:21 -07:00
Andrew Kelley
4307436b99 move behavior tests from test/stage1/ to test/
And fix test cases to make them pass. This is in preparation for
starting to pass behavior tests with self-hosted.
2021-04-29 15:54:04 -07:00