8709 Commits

Author SHA1 Message Date
William Sengir
6b5c87957b stage2: handle vectors in Value.intFitsInType 2022-05-16 13:55:26 -07:00
William Sengir
ca1ab38d3a stage2: add global Type constant for u1 2022-05-16 13:55:26 -07:00
William Sengir
c2cb9b7cad stage2: vectorize shl_with_overflow in LLVM backend 2022-05-16 13:55:26 -07:00
William Sengir
c641fb8f05 stage2: fix {add,sub,mul}_with_overflow vectorization in LLVM backend 2022-05-16 13:55:26 -07:00
Jakub Konka
5b03d55c5e x64: rename brk to int3, and MIR to interrupt 2022-05-15 19:52:43 +02:00
Jakub Konka
5f97652da8 x64: remove verbose_mir functionality
Originally I thought interleaving AIR with MIR will be useful, however
as it stands, I have used it very sporadically, and recently, not at
all, and I do not think anyone else is actually using it. If there is
a simple error such as a wrong instruction emitted,
`objdump` is perfectly capable of narrowing it down, while if there's
something more subtle happening, regardless of having `--verbose-mir`
functionality or not, you still gotta go via the debugger which
offers a better view at interleaved source program with the emitted
machine code. Finally, I believe `-femit-asm` when we add it will offer a
more generic substitute.
2022-05-15 18:21:50 +02:00
Luuk de Gram
5138856a72 test harness: Set filename on error return
While calling `next` an error can occur while parsing the file.
However, we don't set the filename that is currently being processed, until `next` completed successfully.
This means that for invalid test names, the wrong filename was being displayed in the panic message.
The fix is to retrieve the correct filename when an error occurs and then setting the filename appropriately.
2022-05-15 09:30:59 +02:00
Andrew Kelley
7d8b90b905 test harness: actually run the stage1 "run" tests 2022-05-13 17:32:23 -07:00
Andrew Kelley
b986fcfc99 test-cases: honor -Dtest-filter argument from zig build 2022-05-13 14:31:02 -07:00
Andrew Kelley
915032715f test harness: dump stderr when compiler crashes 2022-05-13 14:03:20 -07:00
Andrew Kelley
66f3efb63b migrate runtime safety tests to the new test harness
* migrate runtime safety tests to the new test harness
   - this required adding compare output / execution support for stage1
     to the test harness.
 * rename `zig build test-stage2` to `zig build test-cases` since it now
   does quite a bit of stage1 testing actually. I named it this way
   since the main directory in the source tree associated with these
   tests is "test/cases/".
 * add some documentation for the test manifest format.
2022-05-13 14:03:20 -07:00
Kirk Scheibelhut
24633b5613 zig fmt: make --exclude ignore missing dirs 2022-05-13 16:45:00 -04:00
Koakuma
fb0692334e target: Rename sparcv9 -> sparc64
Rename all references of sparcv9 to sparc64, to make Zig align more with
other projects. Also, added new function to convert glibc arch name to Zig
arch name, since it refers to the architecture as sparcv9.

This is based on the suggestion by @kubkon in PR 11847.
(https://github.com/ziglang/zig/pull/11487#pullrequestreview-963761757)
2022-05-13 16:43:59 -04:00
Jakub Konka
6608fa1353
Merge pull request #11628 from ziglang/x64-shifts 2022-05-11 08:24:03 +02:00
Andrew Kelley
b33c8b0b06 Sema: comptime float negation supports negative zero
When handling the `negate` ZIR instruction, Zig now checks for a
comptime operand and handles it as a special case rather than lowering
it as `0 - x` so that the expression `-x` where `x` is a floating point
value known at compile-time, will get the negative zero bitwise
representation.
2022-05-10 21:50:55 -07:00
Andrew Kelley
f5edf78eea
Merge pull request #10143 from nuald/single-threaded-cpp1
Normalized C++ compilation options for single-threaded targets
2022-05-10 23:38:44 -04:00
Andrew Kelley
45415093c6 reduce the scope of this branch
* back out the changes to RunStep
 * move the disabled test to the .cpp code and avoid a confusing
   name-collision with the _LIBCPP macro prefix
 * fix merge conflict with the edits to the same test that ensure global
   initializers are called.

Now this branch is only concerned with single-threaded targets and
passing the correct macro defines to libc++.
2022-05-10 17:31:54 -07:00
Andrew Kelley
1ff9a18cd3 stage1: back out the broken visibility changes
```
$ valgrind ./zig test ../test/behavior.zig -target powerpc-linux-musl -lc -I../test
==2828778== Invalid read of size 1
==2828778==    at 0x6EA0265: LLVMSetVisibility (in /home/andy/Downloads/zig/build/zig)
==2828778==    by 0x1BCE60B: do_code_gen(CodeGen*) (codegen.cpp:9031)
==2828778==    by 0x1BD51E2: codegen_build_object(CodeGen*) (codegen.cpp:10610)
==2828778==    by 0x1BA5C17: zig_stage1_build_object (stage1.cpp:132)
==2828778==    by 0xE61E24: Module.build_object (stage1.zig:149)
==2828778==    by 0xC3D4CE: Compilation.updateStage1Module (Compilation.zig:5025)
==2828778==    by 0xC3117E: Compilation.performAllTheWork (Compilation.zig:2691)
==2828778==    by 0xC2A3ED: Compilation.update (Compilation.zig:2098)
==2828778==    by 0xBB9D1F: main.updateModule (main.zig:3104)
==2828778==    by 0xB16B75: main.buildOutputType (main.zig:2793)
==2828778==    by 0xAD0526: main.mainArgs (main.zig:225)
==2828778==    by 0xACFCB9: main (stage1.zig:48)
```

Since the plan is to ship stage3 for Zig 0.10.0, the stage1
implementation of this hardly matters.
2022-05-10 16:43:51 -07:00
Alexander Slesarev
3997828a61 Added _LIBCPP_HAS_NO_THREADS for single_threaded binaries linked with libcxx.
Fixed single-threaded mode for Windows.
2022-05-10 16:40:48 -07:00
Andrew Kelley
c4c5020f02 fixups to the previous commit
* Rename std.builtin.GlobalVisibility to std.builtin.SymbolVisibility
 * Add missing compile error. From the LLVM language reference: "A
   symbol with internal or private linkage must have default
   visibility."
2022-05-10 15:44:40 -07:00
Takeshi Yoneda
9654a54d4a Add Visibility field to ExportOptions.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
2022-05-10 15:21:48 -07:00
Jakub Konka
3c69810fe6 x64: fix binary not implementation 2022-05-10 21:30:39 +02:00
Jakub Konka
1d3b714125 x64: implement shl with overflow for non-pow-2 2022-05-10 21:19:05 +02:00
Jakub Konka
d31875f7ab x64: implement shl_with_overflow for powers of two 2022-05-10 20:53:44 +02:00
Jakub Konka
2a738599a0 x64: implement missing bits in add_with_overflow and sub_with_overflow 2022-05-10 20:45:57 +02:00
Jakub Konka
f131e41db9 x64: implement shl_exact and shr_exact 2022-05-10 19:34:20 +02:00
Jakub Konka
9725205859 x64: consolidate shifts into single MIR helper fn 2022-05-10 18:52:49 +02:00
Jakub Konka
a9514ae173 x64: handle immediate as RHS of shift bin ops 2022-05-10 18:16:14 +02:00
Jakub Konka
6a4e445f5a x64: pull shl and shr into one helper fn 2022-05-10 17:53:53 +02:00
Jakub Konka
aef3c149e6 x64: refactor genMulDivBinOp helper 2022-05-10 17:25:49 +02:00
Jakub Konka
ef9e3fb2b6 x64: migrate div to genMulDivBinOp 2022-05-10 16:43:44 +02:00
Jakub Konka
85ca14e35a x64: converge add_with_overflow and sub_with_overflow 2022-05-10 09:08:33 +02:00
Jakub Konka
af3ecd04b4 x64: make genBinOp operate on MCValues directly 2022-05-10 09:04:39 +02:00
Jakub Konka
252c5a2339 x64: migrate mod and rem into genBinOp 2022-05-10 01:15:14 +02:00
Jakub Konka
c3b7a5cc26 x64: pass tag and maybe_inst explictly to genBinOp 2022-05-09 23:58:46 +02:00
Jakub Konka
7b9f8bfbd8 x64: migrate mul to new genBinOp helper 2022-05-09 23:50:01 +02:00
Jakub Konka
20e7f1218b x64: make one entry point for binary ops
* rename `genBinMathOp` into `genBinOp` and handle commutativity
* rename `genBinMathOpMir` into `genBinOpMir`
2022-05-09 22:31:36 +02:00
Luuk de Gram
62453496ba wasm: Write nops for padding debug info 2022-05-09 18:51:46 +02:00
Luuk de Gram
2ae2ac33d9 wasm: Emit debug sections
This commit adds the ability to emit the following debug sections:
.debug_info
.debug_abbrev
.debug_line
.debug_str

Line information and files are now being loaded correctly by browser debuggers.
2022-05-09 18:51:46 +02:00
Luuk de Gram
9b6b7034c2 wasm: Flush debug information + commit decl
This implements parts to commit a decl's debug information into
a linear memory buffer. The goal is to write this buffer at once
after we finished linking.
2022-05-09 18:51:46 +02:00
Luuk de Gram
f760272200 wasm: Debug info for lines + pro/epilogue
Maps lines and columns between wasm bytecode and Zig source code.
While this supports prologue and epilogue information, we need to add
support for performing relocations as the offsets are relative to the code section,
which means we must relocate it according to the atom offset's offset while keeping function count
in mind as well (due to leb128 encoding).
2022-05-09 18:51:46 +02:00
Luuk de Gram
d46cdb5396 wasm: Debug information for locals
Implements very basic debug information for locals.
For now it only implements debug info when the variable is stored within a
Wasm local. The goal is to support those that live in the data section (virtual stack).
2022-05-09 18:51:46 +02:00
Luuk de Gram
33b2f4f382 wasm: Implement debug info for parameters 2022-05-09 18:51:46 +02:00
Luuk de Gram
8e1c220be2 wasm: Add basic debug info references 2022-05-09 18:51:46 +02:00
Jakub Konka
9c3d24ea0b x64: add naive impl of shr 2022-05-09 17:39:19 +02:00
Andrew Kelley
d7f8368da8
Merge pull request #11609 from ziglang/win-compiler-rt
compiler-rt: avoid symbol collisions with Windows libc
2022-05-08 19:29:21 -04:00
Hannes Bredberg
ea3f5905f0 Add Win64 calling convention
Closes ziglang/zig#11585
2022-05-08 16:28:10 -04:00
Andrew Kelley
6fde2fcd51 allow in-memory coercion of differently-named floats with same bits
For example, this allows passing a `*c_longdouble` where a `*f80` is
expected, provided that `c_longdouble` maps to `f80` for this target.
2022-05-08 13:05:16 -07:00
Jakub Konka
9416b4d993
Merge pull request #11608 from ziglang/stage2-regalloc 2022-05-08 11:20:14 +02:00
Jakub Konka
f161d3875a
Merge pull request #11605 from Luukdegram/wasm-mul-overflow
stage2: wasm - Improve `@mulWithOverflow` implementation
2022-05-07 23:30:08 +02:00