Commit Graph

2327 Commits

Author SHA1 Message Date
Luuk de Gram 803f9e5dd0 Implement more instructions for more control flow support 2021-03-22 19:56:35 +01:00
Timon Kruiper a710368054 stage2: restructure LLVM backend
The LLVM backend is now structured into 3 different structs, namely
Object, DeclGen and FuncGen. Object represents an object that is
generated by the LLVM backend. DeclGen is responsible for generating
a decl and FuncGen is responsible for generating llvm instructions
from tzir in a function.
2021-03-20 15:10:44 -07:00
jacob gw c50397c268 llvm backend: use new srcloc
this allows to compile with ninja
2021-03-19 14:46:37 -07:00
Andrew Kelley bd2154da3d stage2: the code is compiling again
(with a lot of things commented out)
2021-03-18 22:48:28 -07:00
Andrew Kelley b2682237db stage2: get Module and Sema compiling again
There are some `@panic("TODO")` in there but I'm trying to get the
branch to the point where collaborators can jump in.

Next is to repair the seam between LazySrcLoc and codegen's expected
absolute file offsets.
2021-03-18 22:19:28 -07:00
Jakub Konka d484b3b3cb zld: use aarch64 for opcodes 2021-03-17 19:59:13 +01:00
Tadeo Kondrak e8aa6f90d6 stage2 llvm bindings: use correct type for LLVMBool for ABI compat 2021-03-16 17:05:36 -06:00
Tadeo Kondrak 277b01a089 stage2 llvm bindings: rename LLVMBool to Bool 2021-03-14 22:32:26 -06:00
Andrew Kelley 1f34c03ac1 Merge remote-tracking branch 'origin/master' into llvm12 2021-03-12 18:05:27 -07:00
Veikka Tuominen fc62ff77c3 stage2: error union payload must also be a valid variable type 2021-03-08 00:33:59 +02:00
jacob gw 30ffa052f2 stage2 cbe: add error union and error union operations 2021-03-08 00:33:59 +02:00
Veikka Tuominen 0a7be71bc2 stage2 cbe: non pointer optionals 2021-03-08 00:33:56 +02:00
Veikka Tuominen cfc19eace7 stage2 cbe: errors 2021-03-08 00:33:07 +02:00
Veikka Tuominen c22f010fdd stage2 cbe: regular optional types 2021-03-08 00:33:07 +02:00
Veikka Tuominen ca20d0ea26 stage2 cbe: pointer like optionals 2021-03-08 00:32:52 +02:00
Veikka Tuominen 8c6e7fb2c7 stage2: implement var args 2021-03-06 15:55:29 +02:00
Andrew Kelley bccef44196 Merge remote-tracking branch 'origin/master' into llvm12
Syncing with master branch because I want to re-run
update_clang_options.zig in the llvm12 branch.
2021-03-04 18:23:11 -07:00
Timon Kruiper d4ec0279d3 stage2: add support for optionals in the LLVM backend
We can now codegen optionals! This includes the following instructions:
- is_null
- is_null_ptr
- is_non_null
- is_non_null_ptr
- optional_payload
- optional_payload_ptr
- br_void

Also includes a test for optionals.
2021-03-02 19:02:55 -07:00
Michael Dusan 6fe2fb6cdb std.Target.Abi: add gnuilp32 2021-02-27 11:53:08 -08:00
Andrew Kelley 280195038a std.Target: add powerpcle 2021-02-27 02:51:35 -07:00
Andrew Kelley 0b58b61799 Merge remote-tracking branch 'origin/master' into llvm12
Conflicts:
 * src/clang.zig
 * src/llvm.zig
   - this file got moved to src/llvm/bindings.zig in master branch so I
     had to put the new LLVM arch/os enum tags into it.
 * lib/std/target.zig, src/stage1/target.cpp
   - haiku had an inconsistency with its default target ABI, gnu vs
     eabi. In this commit we make it gnu in both places to match the
     latest changes by @hoanga.
 * src/translate_c.zig
2021-02-25 21:04:23 -07:00
Andrew Kelley 449f4de382 zig fmt src/ 2021-02-24 21:54:23 -07:00
Andrew Kelley 8e6c2b7a47 Merge remote-tracking branch 'origin/master' into ast-memory-layout 2021-02-24 15:08:23 -07:00
Veikka Tuominen ef6aa3d027 Merge pull request #7960 from Luukdegram/wasm-extern
stage2: Add support for extern functions for the wasm backend
2021-02-21 12:22:01 +02:00
Isaac Freund 070e548acf std: remove io.AutoIndentingStream
This type is not widely applicable enough to be a public part of the
public interface of the std.

The current implementation in only fully utilized by the zig fmt
implementation, which could benefit by even tighter integration as
will be demonstrated in the next commit. Therefore, move the current
io.AutoIndentingStream to lib/std/zig/render.zig.

The C backend of the self hosted compiler also use this type currently,
but it does not require anywhere near its full complexity. Therefore,
implement a greatly simplified version of this interface in
src/codegen/c.zig.
2021-02-16 23:20:46 +01:00
joachimschmidt557 c2beaba85a stage2 ARM: fix callee_preserved_regs
Previously, the registers included r0, r1, r2, r3 which are not
included in the callee saved registers according to the Procedure Call
Standard for the ARM Architecture.
2021-02-09 23:57:43 +01:00
Luuk de Gram 36df6a008f Ensure function indices are correct and fix a memory leak 2021-02-05 18:06:25 +01:00
Luuk de Gram aa3e0ff454 Create type declarations for extern functions and write the 'import' section 2021-02-05 18:06:20 +01:00
Andrew Kelley 102d954220 Merge pull request #7827 from Snektron/spirv-setup
Stage 2: SPIR-V setup
2021-02-01 12:49:51 -08:00
Andrew Kelley 1517ed0a5e Merge pull request #7895 from Luukdegram/wasm-control-flow
stage2: wasm control flow
2021-02-01 12:29:22 -08:00
Veikka Tuominen 75acfcf0ea stage2: reimplement switch 2021-02-01 15:45:11 +02:00
Veikka Tuominen 3ec5c9a3bc stage2 cbe: implement not and some bitwise ops 2021-02-01 08:48:24 +02:00
Veikka Tuominen 106520329e stage2 cbe: implement switchbr 2021-02-01 08:48:22 +02:00
Veikka Tuominen 258f3ec5ec stage2 cbe: block results 2021-02-01 08:47:25 +02:00
Veikka Tuominen bdfe3aeab8 stage2 cbe: condbr and breaks 2021-02-01 08:47:25 +02:00
Veikka Tuominen 6ca0ff90b6 stage2 cbe: use AutoIndentingStream 2021-02-01 08:47:25 +02:00
Veikka Tuominen 81c512f35b stage2 cbe: loop instruction 2021-02-01 08:47:25 +02:00
Luuk de Gram cc46c1b902 Add tests, fix locals that are created in blocks like loops, and handle all breaks correctly 2021-01-26 19:47:15 +01:00
Andrew Kelley 4ca1f4ec2e Merge pull request #7846 from LemonBoy/filtertest
stage1: don't filter test blocks with empty label
2021-01-25 10:39:11 -08:00
Luuk de Gram a0d81caec9 Nested conditions and loops support 2021-01-24 14:38:35 +01:00
Andrew Kelley 0d4b6ac741 add LTO support
The CLI gains -flto and -fno-lto options to override the default.
However, the cool thing about this is that the defaults are great! In
general when you use build-exe in release mode, Zig will enable LTO if
it would work and it would help.

zig cc supports detecting and honoring the -flto and -fno-lto flags as
well. The linkWithLld functions are improved to all be the same with
regards to copying the artifact instead of trying to pass single objects
through LLD with -r. There is possibly a future improvement here as
well; see the respective TODOs.

stage1 is updated to support outputting LLVM bitcode instead of machine
code when lto is enabled. This allows LLVM to optimize across the Zig and
C/C++ code boundary.

closes #2845
2021-01-23 18:18:07 -07:00
LemonBoy 134f5fd3d6 std: Update test "" to test where it makes sense 2021-01-22 15:46:58 +01:00
Robin Voetter 1055344673 SPIR-V: Use free list for result id generation 2021-01-19 15:28:17 +01:00
Robin Voetter 801732aebd SPIR-V: OpMemoryModel and basic capability generation 2021-01-19 15:28:17 +01:00
Robin Voetter 71ac82ecb0 SPIR-V: Make emitting binary more efficient 2021-01-19 15:28:17 +01:00
Robin Voetter 02c138fe70 SPIR-V: Add glsl450 and vulkan spir-v operating system definitions 2021-01-19 15:28:17 +01:00
Robin Voetter b2b87b5900 SPIR-V: Linking and codegen setup 2021-01-19 15:28:17 +01:00
Robin Voetter 9a6babf482 SPIR-V: Add generated specification 2021-01-19 15:28:17 +01:00
Andrew Kelley 1a05b54520 update wasm backend to match new Module API
Fixes a logical merge conflict that I didn't notice before.
2021-01-18 14:12:05 -07:00
Andrew Kelley 46dd058d59 Merge pull request #7797 from Luukdegram/wasm-refactor
stage2: wasm - Refactor codegen for wasm similar to other backends
2021-01-18 12:35:52 -08:00