Commit Graph

54 Commits (68cc068a3aa5df8bd1995d10a9133af1fa1ea1d3)

Author SHA1 Message Date
Noam Preil 834e8ac2dc [Stage2/Codegen] Extract REX 2020-05-29 13:33:09 -04:00
Noam Preil 07472fb453 [Stage2/Codegen] Properly handle arch in genCall 2020-05-24 20:49:29 -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 88c8ff6e37 move some files around 2020-05-17 12:08:47 -04:00
Noam Preil e2196a458f Minor cleanup 2020-05-17 12:03:01 -04:00
Noam Preil 13ea698a40 rework x64 genSetReg 2020-05-17 12:03:01 -04:00
Andrew Kelley f2feb4e47a move Module to its own file 2020-05-15 21:44:33 -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 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
Andrew Kelley e3a0fac1a7 self-hosted: link: global offset table support for decls 2020-05-12 20:11:47 -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
Andrew Kelley 751903ba8f zir: add breakpoint() instruction and object file ability 2020-05-01 06:47:20 -04:00
Andrew Kelley f89dbe6c4e link: introduce the concept of output mode and link mode 2020-05-01 06:47:20 -04:00
Andrew Kelley 6b0f7de247 ZIR: add cmp and condbr instructions 2020-05-01 06:47:20 -04:00
Andrew Kelley 058937e44d bug fixes to make it work 2020-04-24 02:09:30 -04:00
Andrew Kelley 2d35f71fa9 codegen rdx set immediate 2020-04-23 20:30:20 -04:00
Andrew Kelley 757d13d784 codegen supports embedded-in-code constants
also coerce no longer requires a bitcast
2020-04-23 20:23:16 -04:00
Andrew Kelley 0ac502f372 codegen for setting rax and rdi registers 2020-04-23 19:40:17 -04:00
Andrew Kelley 63b54bcf51 codegen for inline assembly 2020-04-23 18:58:47 -04:00
Andrew Kelley 99ec614b71 codegen for const ints and string literals 2020-04-23 17:46:01 -04:00
Andrew Kelley 24a01eed90 basics of writing ELF and machine code generation 2020-04-23 16:41:20 -04:00
Andrew Kelley 2e806682f4
(breaking) std.Buffer => std.ArrayListSentineled(u8, 0)
This new name (and the fact that it is a function returning a type) will
make it more clear which use cases are better suited for ArrayList and
which are better suited for ArrayListSentineled.

Also for consistency with ArrayList,
 * `append` => `appendSlice`
 * `appendByte` => `append`

Thanks daurnimator for pointing out the confusion of std.Buffer.
2020-04-01 13:30:07 -04:00
Andrew Kelley 9e7ae06249
std lib API deprecations for the upcoming 0.6.0 release
See #3811
2020-03-30 14:23:22 -04:00
Michaël Larouche 9b11e5e1f1 Add InstallRawStep to Zig build system that does a similar job to llvm-objcopy. To use it, do 'exe.installRaw("kernel.bin");' where exe is a LibExeObjStep
Part of #2826
2020-02-03 15:07:34 -05:00
Andrew Kelley 7c1dbfab72
self-hosted: manually parse args 2019-12-11 02:08:33 -05:00
Andrew Kelley fe4963412f
update self-hosted compiler to new format API 2019-12-08 23:17:03 -05:00
Vexu 36849d8a7b
fixes and cleanup in self hosted 2019-11-26 11:52:12 +02:00
Andrew Kelley 34b1ebefaa
Merge remote-tracking branch 'origin/master' into null-terminated-pointers 2019-11-24 20:28:46 -05:00
Vexu d40f204ec0
self hosted compiler: small miscellaneous fixes 2019-11-23 21:57:24 +02:00
Andrew Kelley 47f06be369
string literals are now null terminated
this also deletes C string literals from the language, and then makes
the std lib changes and compiler changes necessary to get the behavior
tests and std lib tests passing again.
2019-11-21 20:43:41 -05:00
Vexu 86d9563d15
self hosted compiler: various small fixes 2019-11-08 00:18:14 +02:00
Vexu c6076a1360
self hosted compiler: use enum literals 2019-11-07 10:30:56 +02:00
Vexu 6dd4a276de
self hosted compiler: update to new std.event 2019-11-07 10:30:37 +02:00
Vexu cb20093614
self hosted compiler: remove await async pattern 2019-11-07 10:30:11 +02:00
Andrew Kelley 64dddd7afe
add compile error for ignoring error
closes #772
2019-03-23 19:33:00 -04:00
Andrew Kelley 6769183a9d
fix implicit cast error unions with non-optional to optional pointer
and update self hosted compiler for C pointers

See #1059
2019-02-14 15:48:28 -05:00
Jimmi Holst Christensen 8139c5a516
New Zig formal grammar (#1685)
Reverted #1628 and changed the grammar+parser of the language to not allow certain expr where types are expected
2018-11-13 05:08:37 -08:00
Andrew Kelley 2b395d4ede
remove @minValue,@maxValue; add std.math.minInt,maxInt
closes #1466
closes #1476
2018-10-26 15:01:51 -04:00
Jimmi Holst Christensen 378d3e4403
Solve the return type ambiguity (#1628)
Changed container and initializer syntax
* <container> { ... } -> <container> . { ... }
* <exrp> { ... } -> <expr> . { ...}
2018-10-15 09:51:15 -04:00
Andrew Kelley 0df485d4dc self-hosted: reorganize creation and destruction of Compilation 2018-08-10 12:28:20 -04:00
Andrew Kelley adefd1a52b self-hosted: function calling another function 2018-07-24 20:24:05 -04:00
Andrew Kelley 2ea08561cf self-hosted: function types use table lookup 2018-07-24 14:20:49 -04:00
Andrew Kelley 93e78ee722 self-hosted can compile libc hello world 2018-07-22 23:28:53 -04:00
Andrew Kelley aa3b41247f self-hosted: linking against libc
also introduce `zig libc` command to display paths
`zig libc file.txt` will parse equivalent text and use that for libc
paths.
2018-07-18 17:43:36 -04:00
Andrew Kelley ecf8da00c5 self-hosted: linking 2018-07-17 13:18:13 -04:00