Commit Graph

630 Commits

Author SHA1 Message Date
xackus
250dd9ac21 stage1: fix unresolved inferred error sets 2020-05-31 15:04:34 +02:00
foobles
51682717d7 Support equality comparison for optional to non-optional (?T ==/!= T)
extracted function ir_try_evaluate_bin_op_const
extracted type_is_self_comparable function
renamed ir_try_evaluate_bin_op_const to ir_try_evaluate_bin_op_cmp_const
implemented analysis of ?T == T
added ir_set_cursor_at_end_and_append_basic_block_gen
use build_br_gen and ir_set_cursor_at_end_and_append_block_gen
added ir_append_basic_block_gen
removed include of all_types in ir.cpp
extracted compile-time and runtime evaluation of cmp_optional_non_optional to separate functions

closes #5390
closes #1332
2020-05-29 18:46:09 -04:00
Veikka Tuominen
4c8b937fb0
Merge pull request #5184 from alexnask/typeof_extern_call
Extern functions are now evaluated to undefined values at comptime in TypeOf calls.
2020-05-30 01:11:22 +03:00
Timon Kruiper
6e89692d81 C ABI: Add C support for passing structs of floats to an extern function
Currently this does not handle returning these structs yet.

Related: #1481
2020-05-28 22:56:33 -04:00
Jakub Konka
015c899297 Make align expr on fns a compile error in Wasm
In Wasm, specifying alignment of function pointers makes little sense
since function pointers are in fact indices to a Wasm table, therefore
any alignment check on those is invalid. This can cause unexpected
behaviour when checking expected alignment with `@ptrToInt(fn_ptr)`
or similar. This commit proposes to make `align` expressions a
compile error when compiled to Wasm architecture.

Some references:
[1] [Mozilla: WebAssembly Tables](https://developer.mozilla.org/en-US/docs/WebAssembly/Understanding_the_text_format#WebAssembly_tables)
[2] [Sunfishcode's Wasm Ref Manual](https://github.com/sunfishcode/wasm-reference-manual/blob/master/WebAssembly.md#indirect-call)
2020-05-26 17:17:32 +02:00
Alexandros Naskos
d88db4d34b Changed test name to reflect it only fixes #4328 2020-05-26 12:36:02 +03:00
Alexandros Naskos
75a4c02880 Updated test 2020-05-18 19:28:26 +03:00
Alexandros Naskos
400a91e1c6 Add TypeOf resolution of dereferences and struct fields of undefined values 2020-05-18 19:15:44 +03:00
Jakub Konka
34f84c3608 Narrow down behaviour test cases; this removes wasmtime-enabled check in tests 2020-05-18 17:56:17 +02:00
Vexu
0847b47bf8
fix @intToFloat on comptime_floats 2020-05-12 00:24:09 +03:00
Tadeo Kondrak
6745a6f6f6
zig fmt 2020-05-05 09:38:02 -06:00
Tadeo Kondrak
2c9204032d
update tests for nosuspend 2020-05-05 05:55:26 -06:00
Tadeo Kondrak
af00afed98
zig fmt 2020-05-05 05:55:25 -06:00
Andrew Kelley
b7914d901c add test coverage for top level fields
closes #2022
2020-05-02 14:53:20 -04:00
Tadeo Kondrak
350b2adacd
std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
Andrew Kelley
5929e5ca0e
Merge pull request #5196 from tadeokondrak/@vector-to-@type-vector
`@Vector` -> `@Type(.Vector)`
2020-04-28 16:25:40 -04:00
Tadeo Kondrak
f977155fdb
@Vector -> std.meta.Vector 2020-04-28 00:47:13 -06:00
Tadeo Kondrak
17e41f6cd3
@OpaqueType -> @Type(.Opaque) 2020-04-28 00:02:13 -06:00
Tadeo Kondrak
45f4a1124f implement @Type() for more types 2020-04-27 14:37:18 -04:00
Alexandros Naskos
37fa418a94 Cleaned up code, added a testcase for an extern member function call 2020-04-27 18:07:18 +03:00
Alexandros Naskos
908b908481 Added tests. 2020-04-27 15:22:15 +03:00
Timon Kruiper
c829f2f7b7 Add mips support to standard library 2020-04-24 15:28:55 -04:00
LemonBoy
e6428f9401
stage1: Fix bitcast of immediate to ptr type (#5131)
Consider a (legal according to the `@bitCast` rules) conversion from u16
to [2]u8: since the former is a scalar and the latter is a pointer
(arrays are represented at pointers in the codegen phase) we have to
allocate a temporary slot on the stack and then bitcast the resulting
pointer to the desired destination type.

Beware that this means the lifetime of the resulting value is the same
of the function it's contained in and for all intents and purposes
should be regarded as a local (eg. it should not escape).

Closes #4395
Closes #5121
2020-04-23 12:44:16 -04:00
LemonBoy
b5e72c0148 stage1: Prevent the creation of illegal pointer types
Changing the pointer length from Unknown to Single/C now resets the
sentinel value too.

Closes #5134
2020-04-22 14:40:57 -04:00
elucent
48dc3b6fe9 Added peer type resolution for [*]T and *[N]T. 2020-04-21 18:09:03 -04:00
Vexu
4f02cf32b4
fix typeInfo tests 2020-04-18 11:39:52 +03:00
LemonBoy
8e96922f31 stage1: Fix several bugs in constant generation
The codegen would sometimes change the LLVM type for some constants to
an unnamed structure in order to accomodate extra padding. This is fine
as long as the alignment of each field is still respected and it was not
the case for structure types, leading to ill-formed constants being
generated.

Optional types suffer from this to a lower extent as their layout is
quite lucky, the only missing piece was the tail padding.

Closes #4530
Closes #4594
Closes #4295
Closes my will to live
2020-04-17 13:42:23 -04:00
Vexu
ca3bf6e6ad
translate-c cleanup and zig fmt 2020-04-15 15:15:32 +03:00
LemonBoy
ce21a784a4 stage1: More fixes for BE targets
* Fix packed struct alignment
* Adjust some tests
2020-04-13 17:35:14 -04:00
xackus
66b2477ab6 fix lazy value in ir_analyze_instruction_elem_ptr 2020-04-07 18:22:17 -04:00
Vexu
95fefcd4c9
fix broken tests 2020-04-07 16:56:48 +03:00
LemonBoy
a59d31bd28 ir: Support tuple multiplication 2020-04-06 14:03:43 -04:00
Andrew Kelley
e84b9b70ff
annotate disabled tests with github issue links 2020-04-05 18:34:32 -04:00
LemonBoy
0f964e1910
I'm getting tired of this shit LLVM 2020-04-05 18:34:31 -04:00
LemonBoy
91a8e3b47b
tests: Chop away some flaky tests 2020-04-05 18:34:31 -04:00
LemonBoy
d2d97e55cc
ir: Support shift left/right on vectors 2020-04-05 18:34:31 -04:00
LemonBoy
2485f30046
ir: Support bitwise not on vectors 2020-04-05 18:34:31 -04:00
LemonBoy
54ffcf95a8
ir: Support div/mod/rem on vector types
Closes #4050
2020-04-05 18:34:31 -04:00
Andrew Kelley
e2dc63644a
type_has_one_possible_value takes comptime struct fields into account
Before, type_has_one_possible_value would return false for the value
`.{1}`. But actually, that type is a tuple with a single comptime field.
Such a type, in fact, has one possible value.

This plus the corresponding adjustment to get_the_one_possible_value
solves #3878.
2020-04-05 17:09:01 -04:00
Michael Dusan
db4c06ce60 stage1: add compile errors for sentinel slicing
closes #3963
2020-04-03 19:05:30 -04:00
Andrew Kelley
47a0e3ec5e
Merge pull request #4871 from boothby/issue4769
Address bugs when //, /// or //! are immediately followed by EOF
2020-03-31 10:56:21 -04:00
Kelly Boothby
44aadaff59 added unit tests to demonstrate #4769 and related bugs 2020-03-30 18:29:48 -07:00
Andrew Kelley
9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
Andrew Kelley
b980568c81
add peer type resolution for mixed-const []T and *[N]T
closes #4766

This commit also fixes the implementation of some utility functions for
adjusting properties of pointer types. Previously these functions would
incorrectly drop vector, sentinel, and inference metadata.
2020-03-30 13:02:50 -04:00
LemonBoy
c1cc1ebc35 ir: Avoid constant-folding ptr to sentinels
Constant-folding the pointers to the expected sentinel value have some
big problems: it hides the real content of the array, makes the pointer
to the sentinel point to a completely different memory region and treats
it like a const value even when the underlying array is mutable.

Fixes #4840
2020-03-30 11:03:56 -04:00
Andrew Kelley
c70471fae6
enable now-passing test cases
These can now be enabled thanks to bug fixes that landed in
LLVM 10.
2020-03-29 10:34:12 -04:00
Andrew Kelley
ddd98a7f10
prevent ptr cast from forcing alignment resolution unnecessarily 2020-03-26 12:34:16 -04:00
Andrew Kelley
93c7fa105f
Merge remote-tracking branch 'origin/llvm10'
LLVM 10 was released today
2020-03-24 09:57:09 -04:00
LemonBoy
0cd953d40e ir: Prevent crash when slicing hardcoded pointer
Closes #4780
2020-03-23 09:13:52 -04:00
Andrew Kelley
13d04f9963
Merge pull request #4741 from momumi/master
allow `_` separators in number literals (stage 1)
2020-03-23 00:54:54 -04:00