151 Commits

Author SHA1 Message Date
Andrew Kelley
d18b6785bb stage2: C backend improvements
* Module: improve doc comments
 * C backend: improve const-correctness
 * C backend: introduce renderTypeAndName
 * C backend: put `static` on functions when appropriate
 * C backend: fix not handling errors in genBinOp
 * C backend: handle more IR instructions
   - alloc, store, boolean comparisons, ret_ptr
 * C backend: call instruction properly stores its result
 * test harness: ensure execution tests have empty stderr
2020-12-29 17:56:30 -07:00
Andrew Kelley
813d3308cc stage2: update C backend test cases for new output 2020-12-28 20:32:13 -07:00
Andrew Kelley
7561fca435 stage2: improve test harness to support executing generated C code 2020-12-28 20:01:17 -07:00
Andrew Kelley
a54ccd8537 stage2: C backend: implement @breakpoint and clean up test harness 2020-12-28 18:43:01 -07:00
Andrew Kelley
f75d4cbe56 Revert "stage2: add compile log statement (#7191)"
The addition of `addDeclErr` introduced a memory leak at every call
site, and I also would like to push back on having more than 1
compilation error per `Decl`.

This reverts commit 1634d45f1d53c8d7bfefa56ab4d2fa4cc8218b6d.
2020-12-28 11:24:53 -07:00
g-w1
d6e9862049 add test for @compileError in zig code, not only zir 2020-12-26 11:34:15 -05:00
g-w1
7f512f2236 fix test cases to use str zir inst instead of just a quoted string 2020-12-26 11:22:16 -05:00
Veikka Tuominen
641bf4c46e
Merge pull request #7552 from Vexu/stage2-continue
stage2 continue
2020-12-26 12:26:16 +02:00
g-w1
1634d45f1d
stage2: add compile log statement (#7191) 2020-12-26 02:40:49 +02:00
Veikka Tuominen
a50759325c
stage2: add error for unused labels 2020-12-26 02:36:12 +02:00
Veikka Tuominen
40aad4f47e
stage2: break and continue out of loops 2020-12-26 02:26:53 +02:00
Veikka Tuominen
ce7dcf2294
Merge pull request #7507 from joachimschmidt557/stage2-arm
stage2 ARM: implement basic binary bitwise operations
2020-12-23 12:17:40 +02:00
g-w1
cb3198af2a
stage2: @TypeOf (#7475)
* stage2: add @TypeOf

* stage2: discriminate on what type of @builtinCall in nodeMayNeedMemoryLocation

* merge upstream into my stash

* add type equality to make easier to test and defer free the types

* remove addDeclErr, I dont know why I added it, its from a different branch that im working on

* add tests

* update error message to match stage1

* use ComptimeStringMap and update which nodes don't need memory from vexu's suggestions

* fix typo

Co-authored-by: Veikka Tuominen <git@vexu.eu>

* make @TypeOf(single_arg) go to .typeof zir inst and add test for that

* unioninit, as, reduce change mayneedmemorylocation

Co-authored-by: Veikka Tuominen <git@vexu.eu>
2020-12-23 01:26:36 +02:00
Alex Cameron
58bd6c5f8e Add tests for emit-h functionality. 2020-12-23 01:14:35 +11:00
Noam Preil
8538053940 Add header test harness 2020-12-23 01:14:35 +11:00
joachimschmidt557
45a88be573
stage2 ARM: add test cases for binary bitwise operations 2020-12-21 19:24:23 +01:00
g-w1
6294c1136c
stage2: variable shadowing detection (#6969) 2020-12-06 19:36:49 +02:00
Andrew Kelley
2ed1ed9b32 stage2: introduce Module.failed_root_source_file
Use case:

zig build-exe non_existent_file.zig

Previous behavior:

error.FileNotFound, followed by an error return trace

Behavior after this commit:

error: unable to read non_existent_file.zig: FileNotFound
(end of stderr, exit code 1)

This turns AllErrors.Message into a tagged union which now has the
capability to represent both "plain" errors as well as source-based
errors (with file, line, column, byte offset). The "no entry point found"
error has moved to be a plain error message.
2020-12-04 17:21:55 -07:00
Timon Kruiper
ac85e1f2c8 stage2: make sure to emit the ZIR instructions of exported functions
Previously the emitted ZIR code would not have the ZIR instructions
of the exported functions.
2020-12-03 11:46:35 -08:00
joachimschmidt557
ceebcb2b4d
stage2 ARM: add test case for addition 2020-11-28 23:26:17 +01:00
Jakub Konka
f125c4f5c7 stage2 macho: enable end-to-end incremental linking tests on aarch64 2020-11-26 11:50:09 +01:00
joachimschmidt557
b17859b568
stage2 AArch64: add Linux Hello World test 2020-11-11 23:29:18 +01:00
Jakub Konka
5b92d0ea45 stage2 aarch64: add macOS incremental test 2020-11-11 15:36:47 +01:00
Veikka Tuominen
9ca9819488
Merge pull request #6883 from Vexu/translate-c
translate-c: correctly handle pointers to opaque demoted structs
2020-10-31 15:25:14 +02:00
Vexu
28a0583b84
run zig fmt on src/ and test/ 2020-10-31 12:21:49 +02:00
Vexu
22ec5e0859
stage2: fix typo in liveness; add comptime switch test 2020-10-30 15:58:13 +02:00
Andrew Kelley
245d98d32d
Merge pull request #6291 from pixelherodev/cbe_arithmetic
CBE: addition and subtraction
2020-10-17 01:00:38 -04:00
Andrew Kelley
d91e75f5ca getExternalExecutor fixups regarding dynamic linker
* std.Target.standardDynamicLinkerPath: macOS has a dynamic linker
 * no need to override the default dynamic linker in the macos
   CrossTarget initialization in the tests
 * in getExternalExecutor, when validating the dynamic linker path, take
   into account the standard dynamic linker path.
2020-10-15 16:44:16 -07:00
Jakub Konka
0e1afee732 Enable stage2 end-to-end tests on macOS run natively
This commit enables stage2 end-to-end tests to run natively on macOS
(where and when applicable). Since QEMU on macOS doesn't support
the same type of architecture emulation as it does on linux (i.e.,
there is no `qemu-x86_64` for instance), this commit ensures that we
specify a path to dynamic linker on macOS (`/usr/lib/dyld`) which
is then checked for existence in `std.CrossTarget.getExternalExecutor()`
function, and if exists, we can run the test natively.

Signed-off-by: Jakub Konka <kubkon@jakubkonka.com>
2020-10-15 15:59:16 -07:00
Jakub Konka
951721343f Reuse text blocks; enable all incremental tests 2020-10-13 08:38:17 +02:00
Jakub Konka
cf2aea7b41 Enable incremental testcase for macOS 2020-10-13 08:38:17 +02:00
Vignesh Rajagopalan
2ab0c7391a Rename .macosx to .macos 2020-10-12 18:56:25 -04:00
Noam Preil
de093879cc
Fix peer type resolution 2020-10-07 02:31:47 -04:00
Noam Preil
ea7b2750c8
CBE: addition and subtraction 2020-10-06 15:09:57 -04:00
Andrew Kelley
da596b7e4f
Merge pull request #6255 from joachimschmidt557/stage2-arm
stage2 ARM: more instructions, return values, parameters
2020-10-04 19:49:18 -04:00
Andrew Kelley
6aa668e020
Merge pull request #6476 from kubkon/macho-exe
Link basic MachO executables with stage2
2020-10-04 19:05:45 -04:00
Jakub Konka
f8dd48bcd2 Fix after rebase and enable stage2 tests for macOS
Also, rewrites codegen section to store symbol address in a register
to then later invoke `callq` on the register.
2020-10-04 15:31:47 +02:00
joachimschmidt557
fb58fb2d8d stage2 ARM: add testcases for non-leaf fns, parameters, return values 2020-10-03 12:52:04 +02:00
Vexu
d819da4350
stage2: support multiple files in tests 2020-09-30 17:00:57 +03:00
Andrew Kelley
afac5d2895 fix regressed stage2 test harness 2020-09-21 21:14:01 -07:00
Andrew Kelley
2a8fc1a18e stage2: caching system integration & Module/Compilation splitting
* update to the new cache hash API
 * std.Target defaultVersionRange moves to std.Target.Os.Tag
 * std.Target.Os gains getVersionRange which returns a tagged union
 * start the process of splitting Module into Compilation and "zig
   module".
   - The parts of Module having to do with only compiling zig code are
     extracted into ZigModule.zig.
   - Next step is to rename Module to Compilation.
   - After that rename ZigModule back to Module.
 * implement proper cache hash usage when compiling C objects, and
   properly manage the file lock of the build artifacts.
 * make versions optional to match recent changes to master branch.
 * proper cache hash integration for compiling zig code
 * proper cache hash integration for linking even when not compiling zig
   code.
 * ELF LLD linking integrates with the caching system. A comment from
   the source code:

   Here we want to determine whether we can save time by not invoking LLD when the
   output is unchanged. None of the linker options or the object files that are being
   linked are in the hash that namespaces the directory we are outputting to. Therefore,
   we must hash those now, and the resulting digest will form the "id" of the linking
   job we are about to perform.
   After a successful link, we store the id in the metadata of a symlink named "id.txt" in
   the artifact directory. So, now, we check if this symlink exists, and if it matches
   our digest. If so, we can skip linking. Otherwise, we proceed with invoking LLD.

 * implement disable_c_depfile option
 * add tracy to a few more functions
2020-09-13 19:29:07 -07:00
Andrew Kelley
12ce6eb8f6 stage2: support dbg_stmt at comptime 2020-09-02 00:09:24 -07:00
Andrew Kelley
4c13d020db stage2: proper split of requireRuntimeBlock and requireFunctionBlock
* improve the ZIR generated of variable decls
   - utilize the same ZIR for the type and init value when possible
   - init value gets a result location with the variable type.
     no manual coercion is required.
 * no longer use return instructions to extract values out of comptime
   blocks. Instead run the analysis and then look at the corresponding
   analyzed instruction, relying on the comptime mechanism to report
   errors when something could not be comptime evaluated.
2020-09-01 12:39:47 -07:00
Andrew Kelley
717b0e8275 stage2: introduce the ability for Scope.Block to be comptime
This gives zir_sema analysis the ability to check if the current scope
is expected to be comptime.
2020-08-31 23:34:58 -07:00
Vexu
cc26cb9b23 stage2: codegen needed for basic for loop 2020-08-26 19:50:56 -07:00
Vexu
bf014d529a stage2: array access astgen 2020-08-26 19:50:56 -07:00
Andrew Kelley
0c5faa61ae stage2: codegen: fix reuseOperand not doing death bookkeeping 2020-08-26 01:00:04 -07:00
joachimschmidt557
4f2618e75b stage2: Add Hello World test for ARM backend 2020-08-23 23:13:41 +02:00
Andrew Kelley
54f3b0a560 stage2: clean up SPU Mk II code
* move SPU code from std to self hosted compiler
 * change std lib comments to be descriptive rather than prescriptive
 * avoid usingnamespace
 * fix case style of error codes
 * remove duplication of producer_string
 * generalize handling of less than 64 bit arch pointers
 * clean up SPU II related test harness code
2020-08-22 13:36:08 -07:00
Noam Preil
f2fef240a1 SPU-II: Test harness skeleton 2020-08-22 12:45:29 -07:00