Commit Graph

10029 Commits

Author SHA1 Message Date
Andrew Kelley
2cd19c05d0 stage1: remove buggy "unable to inline function" compile error
We still want this compile error but I'm giving up on implementing it
correctly in stage1. It's been buggy and has false positives sometimes.

I left the test cases there, but commented out, so that when we go
through the stage1 compile error cases and get coverage for them in
stage2 we can reactivate the test cases.

closes #2154
2020-08-15 09:53:39 -07:00
Andrew Kelley
0f3f96c850 stage2: astgen for labeled blocks and labeled breaks 2020-08-15 00:52:25 -07:00
Andrew Kelley
f356cba704 stage2: populate some of the astgen switch possibilities
Idea here is simply to entice people to contribute astgen code :)
2020-08-14 22:50:00 -04:00
Andrew Kelley
b49d3672f3 stage2 astgen for LabeledBlock 2020-08-14 22:50:00 -04:00
Andrew Kelley
9a5a1013a8 std.zig.ast: extract out Node.LabeledBlock from Node.Block
This is part of an ongoing effort to reduce size of in-memory AST. This
enum flattening pattern is widespread throughout the self-hosted
compiler.

This is a API breaking change for consumers of the self-hosted parser.
2020-08-14 22:50:00 -04:00
Michael Dusan
c12a262503
Merge pull request #6051 from mikdusan/qemu
ci linux: bump qemu-5.1.0
2020-08-14 17:54:22 -04:00
Andrew Kelley
7a39a038db stage2: proper semantic analysis of improper returning of implicit void 2020-08-14 13:08:55 -07:00
Michael Dusan
05f80311bc
ci linux: bump qemu-5.1.0 2020-08-14 14:38:54 -04:00
Andrew Kelley
5f7c7191ab stage2: astgen for non-labeled blocks 2020-08-14 11:28:40 -07:00
Andrew Kelley
4adc052f0b langref: fix html error
thanks tidy
2020-08-14 09:33:45 -07:00
Andrew Kelley
28a9da8bfc stage2: implement while loops (bool condition)
* introduce a dump() function on Module.Fn which helpfully prints to
   stderr the ZIR representation of a function (can be called before
   attempting to codegen it). This is a debugging tool.
 * implement x86 codegen for loops
 * liveness: fix analysis of conditional branches. The logic was buggy
   in a couple ways:
   - it never actually saved the results into the IR instruction (fixed now)
   - it incorrectly labeled operands as dying when their true death was
     after the conditional branch ended (fixed now)
 * zir rendering is enhanced to show liveness analysis results. this
   helps when debugging liveness analysis.
 * fix bug in zir rendering not numbering instructions correctly

closes #6021
2020-08-13 20:32:32 -07:00
Andrew Kelley
576581bd7b stage1: fix enums having wrong debug info
It wasn't wrong info, but e.g. GDB couldn't handle non-power-of-two
enum tags. Now we tell debug info that enum tags are always power of two
size.

closes #4526
closes #5432
2020-08-13 20:32:32 -07:00
Andrew Kelley
fc402bdbbb stage2: zir_sema for loops
Also remove the "repeat" instruction and make it implied to be at the
end of a Loop body.
2020-08-13 20:32:32 -07:00
Dmitry Atamanov
a9590f3bf8
Support tuples in mem.len and trait.isIndexable (#5897) 2020-08-14 01:14:32 +03:00
Veikka Tuominen
f5b99abc93
Merge pull request #6045 from Vexu/block
Add error for unused/duplicate labels.
2020-08-14 01:04:05 +03:00
Maks S
50139aa232
langref: explain why comptime_float cannot be divided by comptime_int
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
Co-authored-by: Veikka Tuominen <git@vexu.eu>
2020-08-13 22:08:37 +03:00
Andrew Kelley
6e0fb06010 Merge branch 'Vexu-stage2'
closes #6042
2020-08-13 10:05:20 -07:00
Andrew Kelley
ec4953504a stage2: implement safety checks at the zir_sema level 2020-08-13 10:04:46 -07:00
Vexu
13e472aa2a
translate-c: add return if one is needed 2020-08-13 18:40:14 +03:00
Vexu
6b2ce9d1e9 stage2: split unwrap_optional to safe and unsafe verions 2020-08-13 08:12:17 -07:00
Vexu
4a40282391 stage2: implement unwrap optional 2020-08-13 08:12:17 -07:00
Vexu
5c1fe58613 stage2: gen optional types 2020-08-13 08:12:17 -07:00
Vexu
75eaf15740 stage2: add optional types 2020-08-13 08:12:17 -07:00
Vexu
c5368ba20c
translate-c: ensure generated labels are unique 2020-08-13 15:27:29 +03:00
Koakuma
cb06d62603
Add "ppc" prefix to number-modeled CPUs (#6006)
This is to prevent "expected token 'Symbol', found 'IntLiteral'" errors
when building zig files.
2020-08-13 14:30:38 +03:00
Jakub Konka
3e2e6baee5 Add std.os.getFdPath and std.fs.Dir.realpath
`std.os.getFdPath` is very platform-specific and can be used to query
the OS for a canonical path to a file handle. Currently supported hosts
are Linux, macOS and Windows.

`std.fs.Dir.realpath` (and null-terminated, plus WTF16 versions) are
similar to `std.os.realpath`, however, they resolve a path wrt to this
`Dir` instance.

If the input pathname argument turns out to be an absolute path, this
function reverts to calling `realpath` on that pathname completely
ignoring this `Dir`.
2020-08-13 07:08:39 +02:00
Andrew Kelley
e043396b24 Merge branch 'pixelherodev-cbe'
closes #6007
2020-08-12 22:00:14 -07:00
Andrew Kelley
eec53d67ab stage2: anyerror -> explicit error set 2020-08-12 21:59:40 -07:00
Noam Preil
1eb5aaa4b5 CBE: renderValue pays attention to Type, not Tag 2020-08-12 21:58:21 -07:00
Noam Preil
5a166cead8 CBE: fix handling of IR dependencies 2020-08-12 21:58:21 -07:00
Noam Preil
dbd1e42ef2 CBE: Sorta working intcasts? 2020-08-12 21:58:21 -07:00
Noam Preil
78fe86dcd2 CBE: support unreachable on GCC 2020-08-12 21:58:21 -07:00
Noam Preil
d3eec7d46b CBE: working parameters 2020-08-12 21:58:21 -07:00
Noam Preil
4d778e630a Tests: print generated C on test failure 2020-08-12 21:58:21 -07:00
Noam Preil
dd1f1487e4 CBE: Use zig_noreturn instead of noreturn to avoid namespace conflict 2020-08-12 21:58:21 -07:00
Noam Preil
b59e2c1e00 CBE: improve noreturn definition, support noreturn on MSVC 2020-08-12 21:58:21 -07:00
Andrew Kelley
de4f3f11f7 stage2: astgen for while loops
See #6021
2020-08-12 21:13:16 -07:00
Andrew Kelley
30db5b1fb2
Merge pull request #6039 from heidezomp/std-log-scoped
std.log: add scoped logging struct
2020-08-12 18:26:35 -04:00
Vexu
3734881577
add error for unused/duplicate block labels 2020-08-13 01:13:17 +03:00
heidezomp
bf2ed0f571 std.log: don't state in docs that messages are logged to stderr
Since the logger implementation can be overridden, the messages might
not be logged to stderr at all.
2020-08-12 15:54:21 +02:00
heidezomp
25607079f0 std.log: add documentation for scoped logging
* Add short documentation to std.log.scoped and std.log.default
 * Update the module documentation and example to explain the difference
   between using explicit scopes, using a scoped logging namespace, and
   using the default namespace
2020-08-12 15:37:56 +02:00
heidezomp
7db2c11537 std.log: add scoped logging struct
* Add a std.log.scoped function that returns a scoped logging struct
 * Add a std.log.default struct that logs using the .default scope

Implementation of daurnimator's proposal:
https://github.com/ziglang/zig/issues/5943#issuecomment-669043489

Note that I named the function "scoped" instead of "scope" so as not to
clash with the scope parameter that is used everywhere; this seemed a
better solution to me than renaming the scope parameter to "s" or
"log_scope" or the like.
2020-08-12 14:03:02 +02:00
Josias
67d684d89a docs: Fix reference to General Purpose Allocator 2020-08-12 05:08:41 -04:00
Andrew Kelley
8282f4271c stage2: basic support for parameters .debug_info
see #6014
2020-08-11 22:23:32 -07:00
Andrew Kelley
a2a5cea286 stage2: emit DW_TAG_subprogram for function Decls
these have the virtual address range, return type, and name.
2020-08-11 19:02:21 -07:00
Andrew Kelley
7612931c80 stage2: set up per-Decl .debug_info 2020-08-11 14:07:06 -07:00
Andrew Kelley
60ce5edaf9 GeneralPurposeAllocator: default to store more stack frames in test mode
Now tests will by default store 8 stack frames per allocation rather
than the normal default of 4.
2020-08-11 14:05:28 -07:00
Andrew Kelley
3ccfd58bb6 std.mem.Allocator: fix not passing return_address
This makes collected stack traces omit less useful frames. For user
applications which only store a fixed number of stack frames this can
make a big difference.
2020-08-11 14:04:08 -07:00
Maciej Walczak
6febe7e977
copy_file_range linux syscall (#6010) 2020-08-11 15:49:43 -04:00
Vexu
2b28cebf64
translate-c: use mangled name when macro translation fails
Closes #6009
2020-08-11 12:24:45 +03:00