1621 Commits

Author SHA1 Message Date
Jakub Konka
601e831f1d Add builtin for llvm.wasm.memory.grow.i32 intrinsic
This will allow the developer to request additional memory pages
from the runtime to be allocated for the Wasm app. Typical usage:

```zig
var wasm_pages = @wasmMemorySize();
@wasmMemoryGrow(1);
@import("std").debug.assert((wasm_pages + 1) == @wasmMemorySize());
```
2020-06-09 00:22:17 -04:00
Jakub Konka
ce3f0077cf Add builtin for llvm.wasm.memory.size.i32 instrinsic
This will allow the developer to poll the runtime for currently
allocated memory in the number of Wasm pages. Typical usage:

```zig
var wasm_pages = @wasmMemorySize();
@import("std").debug.assert(wasm_pages > 0);
```
2020-06-09 00:22:17 -04:00
Andrew Kelley
9ee98f103b
Merge pull request #5539 from mikdusan/issue5474
stage1: fix constness in some corner cases
2020-06-09 00:12:57 -04:00
xackus
0d40cb6255 stage1: fix crash on slice byte reinterpretation 2020-06-08 17:19:06 -04:00
Michael Dusan
c0c9d11d8c
stage1: fix constness in some corner cases
- for one-possible-value types, ir_analyze_struct_field_ptr()
  no longer hardcodes const/volatile

- when slicing arrays, ir_analyze_instruction_slice()
  no longer consults ConstValSpecialStatic

closes #5474
2020-06-05 00:49:57 -04:00
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
foobles
cb6bc5bdb5
Add caller location tracking for asserts (ir_assert, src_assert, ir_assert_gen) (#5393) 2020-05-26 12:55:31 -04:00
Andrew Kelley
c432811d96 fix regression in compile errors 2020-05-23 20:27:09 -04:00
Andrew Kelley
140dc2f43e stage1: fix false positive redeclared variable compile error 2020-05-20 23:13:02 -04:00
Alexandros Naskos
400a91e1c6 Add TypeOf resolution of dereferences and struct fields of undefined values 2020-05-18 19:15:44 +03:00
Andrew Kelley
9a22c8b6ca
Merge pull request #5057 from xackus/opaque-param
stage1: fix assert fail on opaque fn ptr param
2020-05-17 12:48:56 -04:00
Vexu
0847b47bf8
fix @intToFloat on comptime_floats 2020-05-12 00:24:09 +03:00
Vexu
f2d3266075
Merge pull request #4932 from Qix-/fix-private-access
Fix private access
2020-05-08 18:21:15 +03:00
Josh Junon
4a5c58dd35
fix private member checking for non-canonical invocations (fixes #4909) 2020-05-08 14:26:13 +03:00
xackus
2c9effc101 stage1: handle all cases of invalid struct field default value 2020-05-07 16:39:16 -04:00
Andrew Kelley
e6955688ac
Merge pull request #5272 from tadeokondrak/noasync-to-nosuspend
Noasync to nosuspend
2020-05-05 11:21:02 -04:00
Tadeo Kondrak
b957dc29a4
Rename noasync to nosuspend in C++ compiler 2020-05-05 05:17:34 -06:00
Vexu
f127dee474
Merge pull request #5267 from Vexu/const-call
Fix missing compile error on call assigned to const
2020-05-04 21:45:15 +03:00
Vexu
adc444ceeb
fix missing compile error on call assigned to const 2020-05-04 14:28:58 +03:00
xackus
0db9e90e8f stage1: fix assert fail on opaque fn ptr param 2020-05-04 06:51:37 +02:00
Michael Dusan
09d6dc1ce6
stage1: cleanup
- remove unused IrInstSrcOptionalUnwrapPtr.initializing
2020-05-01 18:01:21 -04:00
Tadeo Kondrak
249938dde0
Validate vector types for @Vector 2020-04-28 00:24:45 -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
Alexandros Naskos
179423ec27 Extern functions can now be evaluated to undefined values in TypeOfs 2020-04-27 02:33:21 +03:00
LemonBoy
a7a8c433d0 stage1: Prevent the creation of illegal ptr types
Closes #5140
2020-04-24 15:55:32 -04:00
xackus
a9eb4a6740 stage1: fix crash on accessing an array of size zero with runtime index 2020-04-23 12:45:32 -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
Andrew Kelley
e8545db9d4
Merge pull request #5130 from ziglang/stage2-ir
beginnings of non-LLVM self-hosted backend
2020-04-22 14:42:46 -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
Andrew Kelley
2cdbb5f472 ir: analyze int casting 2020-04-21 19:48:59 -04:00
elucent
48dc3b6fe9 Added peer type resolution for [*]T and *[N]T. 2020-04-21 18:09:03 -04:00
Michael Dusan
412aac8a70 cleanup: IrBasicBlockGen
remove unused param from `ir_ref_inst_gen`
2020-04-21 18:07:48 -04:00
Michael Dusan
73677e178d cleanup: IrBasicBlockGen
remove unused members { parent, index, ref_count }
2020-04-21 18:07:48 -04:00
LemonBoy
aca6b70184 stage1: Handle errors when generating block IR
Closes #5005
2020-04-20 22:39:34 -04:00
xackus
d415ffd7d9 fix uninitialized ZigValue 2020-04-19 03:49:36 -04:00
Vexu
4f02cf32b4
fix typeInfo tests 2020-04-18 11:39:52 +03:00
Vexu
1afaf42525
add error for non-exter variadic functions 2020-04-17 22:02:49 +03:00
Vexu
c026a9f6d2 fix missing compile errors on builtin cast functions 2020-04-17 14:22:20 -04:00
foobles
022a71ca7d
Shift error message now says "fixed-width integer type" instead of just "integer type" (#5028)
* error message of ir_analyze_bit_shift now more accurate/specific

* fixed compile error test to match bit shift error message
2020-04-14 16:19:45 -04:00
Vexu
f60e7348d5
add error message for invalid assignment 2020-04-09 11:50:32 +03:00
Andrew Kelley
beae932e0f
Merge pull request #4975 from Vexu/param-reassign
Fix missing compile error on assign to slice and array parameters
2020-04-08 21:02:50 -04:00
Andrew Kelley
c45ba49b8b
fix formatted printing warning
needed to use ZIG_PRI_u64 instead of %lu
2020-04-08 19:30:18 -04:00
Vexu
b1e44adcba
move array and struct const checks to more appropriate places 2020-04-08 14:32:02 +03:00
xackus
66b2477ab6 fix lazy value in ir_analyze_instruction_elem_ptr 2020-04-07 18:22:17 -04:00
Vexu
ff0f97a1bc
fix missing compile error on assign to slice and array parameters 2020-04-08 00:27:14 +03:00
Vexu
e62671f643
fix missing const on address of literal 2020-04-07 15:25:44 +03:00