885 Commits

Author SHA1 Message Date
Andrew Kelley
8c10178a1e golly jeepers it's taking a long time to update translate-c 2020-05-20 13:53:53 -04:00
Noam Preil
70239802c9 [Stage2/Codegen] Fix a typo 2020-05-19 22:27:22 -04:00
Andrew Kelley
8d3cca7fc2 stage2: function calls using the global offset table
so far they don't support parameters or return values
2020-05-19 13:51:46 -04:00
Andrew Kelley
8d812dba30 stage2: set up a trampoline table for functions
However there does not appear to be an x86 encoding for calling an
immediate address. So there's no point of setting this up. We should
just emit an indirect call to the got addr.
2020-05-19 13:33:36 -04:00
Andrew Kelley
16f100b82e
Merge pull request #5307 from ziglang/self-hosted-incremental-compilation
rework self-hosted compiler for incremental builds
2020-05-17 13:53:27 -04:00
Andrew Kelley
b0968abccb update ZIR compare output test to test incremental updates 2020-05-17 13:49:22 -04:00
Andrew Kelley
88c8ff6e37 move some files around 2020-05-17 12:08:47 -04:00
Noam Preil
e198eec76a Document register functions 2020-05-17 12:03:01 -04:00
Noam Preil
773281c1f4 Remove trailing whitespace 2020-05-17 12:03:01 -04:00
Noam Preil
e2196a458f Minor cleanup 2020-05-17 12:03:01 -04:00
Noam Preil
497eb31820 Fix the dumb in x86 too 2020-05-17 12:03:01 -04:00
Noam Preil
638554544a Fix a dumb (thanks daurminator!) 2020-05-17 12:03:01 -04:00
Noam Preil
13ea698a40 rework x64 genSetReg 2020-05-17 12:03:01 -04:00
Andrew Kelley
54820a3005 fix source not being loaded when printing errors 2020-05-16 20:23:15 -04:00
Andrew Kelley
017ecc5148 self hosted repl: close executables between updates
This allows the executable to be executed
2020-05-16 15:44:20 -04:00
Andrew Kelley
b0375978ba self-hosted: remove zig libc command for now
Since it depends on the C++ Windows SDK code. For now, self-hosted is
staying pure self hosted, no C/C++ components.
2020-05-16 13:25:39 -04:00
Andrew Kelley
cd5f69794d cross compile the stage2 tests for the target that they work for 2020-05-16 12:19:31 -04:00
Vexu
74f7d710bb
Merge pull request #5032 from LakeByTheWoods/redo_translate_c
Translate C: Redo Add comment containing c source location for failed decls.
2020-05-16 17:37:19 +03:00
Vexu
3e375ee2b9
translate-c use tagName for token id 2020-05-16 14:17:50 +03:00
Vexu
5ac684ec50
fix building translate-c 2020-05-16 13:05:43 +03:00
Andrew Kelley
69a5f0d797 Merge remote-tracking branch 'origin/master' into self-hosted-incremental-compilation 2020-05-16 01:26:18 -04:00
Andrew Kelley
294bfb3321 stage2 zir tests passing 2020-05-15 23:54:13 -04:00
Andrew Kelley
f2feb4e47a move Module to its own file 2020-05-15 21:44:33 -04:00
Andrew Kelley
5135238f86 ZIR: emit proper string literals 2020-05-15 19:11:00 -04:00
Andrew Kelley
8980f150e9 fix memory leaks of one of the ZIR test cases 2020-05-15 18:54:48 -04:00
Andrew Kelley
e1d4b59c5b self-hosted: update main.zig
After this commit there are no more bit rotted files.
The testing program that was in ir.zig has been moved to main.zig
Unsupported command line options have been deleted, or error messages
added.

The compiler repl is available from the build-exe, build-lib,
build-obj commands with the --watch option.

The main zig build script now builds the self-hosted compiler
unconditionally. Linking against LLVM is behind a -Denable-llvm
flag that defaults to off.
2020-05-15 15:20:42 -04:00
Andrew Kelley
ebb81ebe59 fix the global offset table code and updating decl exports 2020-05-15 01:22:04 -04:00
Andrew Kelley
81a01bd481 fix codegen of sentinel-terminated arrays and .got alignment
we now have an exit(0) program working
2020-05-14 16:34:04 -04:00
Andrew Kelley
0986dcf1cf self-hosted: fix codegen and resolve some analysis bugs 2020-05-14 13:20:27 -04:00
Andrew Kelley
fb947c365e work around stage1 compiler bug
breaking from inside the block with defers in scope triggered
broken LLVM module found: Terminator found in the middle of a basic
block!
2020-05-13 22:20:31 -04:00
Andrew Kelley
6a2425c38c self-hosted: fix the rest of the compile errors 2020-05-13 22:12:38 -04:00
Andrew Kelley
080022f6c6 self-hosted: fix compile errors, except for codegen.zig 2020-05-13 20:06:01 -04:00
Vexu
afab095b61
translate-c remove error set from checkForBuiltinTypedef 2020-05-13 17:53:15 +03:00
Andrew Kelley
a3da584248 self-hosted: ir: implement separated analysis of Decl and Fn 2020-05-12 23:59:46 -04:00
Andrew Kelley
e3a0fac1a7 self-hosted: link: global offset table support for decls 2020-05-12 20:11:47 -04:00
Andrew Kelley
619159cf48 self-hosted: rework the memory layout of ir.Module and related types
* add TypedValue.Managed which represents a Type, a Value, and some
   kind of memory management strategy.
 * introduce an analysis queue
 * flesh out how incremental compilation works with respect to exports
 * ir.text.Module is only capable of one error message during parsing
 * link.zig no longer has a decl table map and instead has structs that
   exist directly on ir.Module.Decl and ir.Module.Export
 * implement primitive .text block allocation
 * implement linker code for updating Decls and Exports
 * implement null Type

Some supporting std lib changes:
 * add std.ArrayList.appendSliceAssumeCapacity
 * add std.fs.File.copyRange and copyRangeAll
 * fix std.HashMap having modification safety on in ReleaseSmall builds
 * add std.HashMap.putAssumeCapacityNoClobber
2020-05-12 01:02:48 -04:00
Andrew Kelley
a32d3a85d2 rework self-hosted compiler for incremental builds
* introduce std.ArrayListUnmanaged for when you have the allocator
   stored elsewhere
 * move std.heap.ArenaAllocator implementation to its own file. extract
   the main state into std.heap.ArenaAllocator.State, which can be
   stored as an alternative to storing the entire ArenaAllocator, saving
   24 bytes per ArenaAllocator on 64 bit targets.
 * std.LinkedList.Node pointer field now defaults to being null
   initialized.
 * Rework self-hosted compiler Package API
 * Delete almost all the bitrotted self-hosted compiler code. The only bit
   rotted code left is in main.zig and compilation.zig
 * Add call instruction to ZIR
 * self-hosted compiler ir API and link API are reworked to support
   a long-running compiler that incrementally updates declarations
 * Introduce the concept of scopes to ZIR semantic analysis
 * ZIR text format supports referencing named decls that are declared
   later in the file
 * Figure out how memory management works for the long-running compiler
   and incremental compilation. The main roots are top level
   declarations. There is a table of decls. The key is a cryptographic
   hash of the fully qualified decl name. Each decl has an arena
   allocator where all of the memory related to that decl is stored.
   Each code block has its own arena allocator for the lifetime of
   the block. Values that want to survive when going out of scope in
   a block must get copied into the outer block. Finally, values must
   get copied into the Decl arena to be long-lived.
 * Delete the unused MemoryCell struct. Instead, comptime pointers are
   based on references to Decl structs.
 * Figure out how caching works. Each Decl will store a set of other
   Decls which must be recompiled when it changes.

This branch is still work-in-progress; this commit breaks the build.
2020-05-10 02:05:54 -04:00
Vexu
f2d3266075
Merge pull request #4932 from Qix-/fix-private-access
Fix private access
2020-05-08 18:21:15 +03:00
Vexu
10abffcd98
fix more private member access 2020-05-08 15:10:38 +03:00
Andrew Kelley
ba43492c0e
Merge pull request #5268 from tadeokondrak/remove-callconv-redundant-syntax
Remove syntax redundant with callconv
2020-05-07 12:42:26 -04:00
Vexu
06e6d39c6c
Merge pull request #5257 from matt1795/scoped-typedef
Add scoped typedef to translate-c
2020-05-06 12:28:30 +03:00
Vexu
c0b269bf46
translate-c: small patch to fix bultin type detection 2020-05-06 11:48:46 +03:00
Matthew Knight
52f0adb305 checkForBuiltinTypedef now returns a string 2020-05-05 23:26:00 -07:00
Tadeo Kondrak
6745a6f6f6
zig fmt 2020-05-05 09:38:02 -06:00
Tadeo Kondrak
7ada59f873
remove nakedcc/stdcallcc/async fn/extern fn fnproto 2020-05-05 09:37:28 -06:00
Matthew Knight
db4833d4d6 moved duplicated code to common functions 2020-05-04 23:45:31 -07:00
Jonathan Marler
75b699b2c6 os.zig: add ETIMEDOUT error case to read function
According to documentation ETIMEDOUT (110) is a valid error code for the read function.  I just had my long-running  (been running for about 7 weeks) network program crash because it did not handle the ETIMEDOUT error code from "read".
2020-05-04 13:48:34 -04:00
Matthew Knight
c5198bd76f added scoped typedef to translate-c 2020-05-02 20:22:43 -07:00
Andrew Kelley
92f3e9c92a remove last use of share_with_child_process 2020-05-02 01:54:36 -04:00
Andrew Kelley
b70e6da914 back to stage2 tests passing 2020-05-01 06:47:56 -04:00