Andrew Kelley
25b1c00c72
stage2: add implicit return void where applicable
2020-07-13 00:08:21 -07:00
Andrew Kelley
8fe63d5042
stage2: peer type resolution with noreturn
2020-07-13 00:08:21 -07:00
Noam Preil
3bad1c16cc
Get basic return test working
2020-07-13 01:49:04 -04:00
pixelherodev
2c882b2e65
CBE: Make C an ObjectFormat instead of a special bool ( #5849 )
2020-07-12 22:56:31 -04:00
Vexu
be1507a7af
update compile error tests and some doc comments
2020-07-12 00:54:07 +03:00
Vexu
e85fe13e44
run zig fmt on std lib and self hosted
2020-07-11 20:41:19 +03:00
Andrew Kelley
7bd0500589
Merge remote-tracking branch 'origin/master' into register-allocation
2020-07-08 20:46:06 -07:00
Andrew Kelley
8e425c0c8d
stage2: if
AST=>ZIR
2020-07-08 20:33:33 -07:00
Noam Preil
6b48634166
CBE: Emit asm decls for now, but rename to make them valid
2020-07-08 14:05:07 -04:00
Andrew Kelley
be0546d877
stage2: implement compare operator AST->ZIR
2020-07-08 07:04:43 +00:00
Andrew Kelley
5e60872060
stage2 misc fixes
2020-07-08 06:56:20 +00:00
Noam Preil
089c056dbe
CBE: Improve resource cleanup
2020-07-07 23:24:30 -04:00
Noam Preil
b91cf15972
CBE: Move standards determination to generated code
2020-07-07 22:57:34 -04:00
Noam Preil
b4c571301b
Stage2: Refactor in preparation for C backend
2020-07-07 14:55:44 -04:00
Andrew Kelley
b55d0193e4
stage2: progress towards Block and CondBr codegen
2020-07-07 08:01:54 +00:00
Andrew Kelley
4d01385e14
fix liveness analysis and not correctly propagating link errors
...
We still flush the ELF file even when there are compile errors.
2020-07-07 03:48:20 +00:00
Andrew Kelley
12737c9a30
stage2: codegen skeleton for cmp and sub
2020-07-06 09:21:57 +00:00
Andrew Kelley
8be8ebd698
stage2: skeleton codegen for x64 ADD
...
also rework Module to take advantage of the new hash map implementation.
2020-07-06 06:10:44 +00:00
Andrew Kelley
8fb392dbb4
stage2: implement liveness analysis
2020-07-05 23:20:08 +00:00
Andrew Kelley
abcd4ea5d8
Merge pull request #5793 from pfgithub/stage-2-testing
...
stage2 + operator and @as builtin
2020-07-05 22:58:05 +00:00
Andrew Kelley
3a89f214aa
update more HashMap API usage
2020-07-05 21:11:42 +00:00
pfg
d4456d92f5
stage2: builtin @as
2020-07-04 15:16:46 -07:00
pfg
1d52438bd5
stage2: InfixOp add
2020-07-04 15:16:46 -07:00
Andrew Kelley
ac6bf53069
stage2: clean up test harness, implement symbol collision detection ( #5708 )
...
* Clean up test harness
* Stage2/Testing: Add convenience wrappers
* Add a `compiles` wrapper case
* fix incremental compilation after error
* exported symbol collision detection
* function redefinition detection for Zig code
* handle missing function names
* Stage2/Testing: Simplify incremental compilation tests
* Stage2/Testing: Update documentation
* Stage2/TestHarness: Improve progress reporting
* Disable test
* Improve Tranform failure output
2020-06-27 21:54:11 -04:00
Noam Preil
80b70470c0
Stage2/Module: Add symbol -> export lookup table
2020-06-27 21:50:59 -04:00
Noam Preil
ffca1569d1
Return instead of branch
2020-06-27 21:39:39 -04:00
Noam Preil
97c41e7152
Disable test
2020-06-27 21:10:44 -04:00
Noam Preil
ab307a22f6
Stage2: remove clearErrors, fix ZIR export collision detection
2020-06-27 07:17:20 -04:00
Noam Preil
c8f60b2e2f
Stage2: handle missing function names
2020-06-26 04:36:17 -04:00
Noam Preil
6510888039
Stage2: function redefinition detection for Zig code
2020-06-26 04:05:41 -04:00
Noam Preil
4a17e008da
Stage2: exported symbol collision detection
2020-06-26 03:17:13 -04:00
Noam Preil
e5a3cb8d71
Stage2: fix incremental compilation after error
2020-06-26 03:16:36 -04:00
Andrew Kelley
130c7fd23b
self-hosted: working towards conditional branching test case
...
New features:
* Functions can have parameters in semantic analysis. Codegen
is not implemented yet.
* Support for i8, i16, i32, i64, u8, u16, u32, u64 primitive
identifiers.
* New ZIR instructions: arg, block, and breakvoid
Implementation details:
* Move Module.Body to ir.Body
* Scope.Block gains a parent field and an optional Label field
* Fix bug in integer type equality comparison.
Here's the test case I'm working towards:
```
@void = primitive(void)
@i32 = primitive(i32)
@fnty = fntype([@i32, @i32], @void)
@0 = str("entry")
@1 = export(@0, "entry")
@entry = fn(@fnty, {
%0 = arg(0)
%1 = arg(1)
%2 = add(%0, %1)
%3 = int(7)
%4 = block("if", {
%neq = cmp(%2, neq, %3)
%5 = condbr(%neq, {
%6 = unreachable()
}, {
%7 = breakvoid("if")
})
})
%11 = returnvoid()
})
```
$ ./zig-cache/bin/zig build-obj test.zir
test.zir:9:12: error: TODO implement function parameters for Arch.x86_64
That's where I left off.
2020-06-26 02:30:14 -04:00
Andrew Kelley
5aa3f56773
self-hosted: fix test regressions
...
I'm allowing incremental compilation of ZIR modules to be broken. This
is not a real use case of ZIR, and the feature requires a lot of code
duplication with incremental compilation of Zig AST (which works great).
2020-06-24 20:28:52 -04:00
Andrew Kelley
fd7a97b3b2
fix memory leak of anonymous decl name
2020-06-24 16:20:02 -04:00
Andrew Kelley
14aa08fcd3
self-hosted: restore ZIR functionality
2020-06-24 03:46:32 -04:00
Andrew Kelley
b1b7708cc8
self-hosted: hook up incremental compilation to .zig source code
2020-06-23 23:29:51 -04:00
Andrew Kelley
d9c1d8fed3
self-hosted: improve handling of anonymous decls
...
* anonymous decls have automatically generated names and symbols, and
participate in the same memory management as named decls.
* the Ref instruction is deleted
* the DeclRef instruction now takes a `[]const u8` and DeclRefStr takes
an arbitrary string instruction operand.
* introduce a `zir.Decl` type for ZIR Module decls which holds
content_hash and name - fields that are not needed for `zir.Inst`
which are created as part of semantic analysis. This improves the
function signatures of Module.zig and lowers memory usage.
* the Str instruction is now defined to create an anonymous Decl and
reference it.
2020-06-23 19:53:32 -04:00
Vexu
7b68385d7d
self-hosted: astGenIntegerLiteral support other bases
2020-06-22 23:19:12 -04:00
Vexu
d98aed6eff
self-hosted: generalize astGenBuiltinCall
2020-06-22 23:19:12 -04:00
Andrew Kelley
c9a0ec25e0
self-hosted: add Tracy integration
...
This tool helps give an intuitive picture of performance. This will help
us understand where to improve the code.
2020-06-18 21:55:37 -04:00
Andrew Kelley
7e44302260
stage2: explicit hash and equality function for the DeclTable
2020-06-18 17:12:56 -04:00
Andrew Kelley
02f688d710
remove std.debug.warn debugging logs
2020-06-18 17:12:56 -04:00
Andrew Kelley
7e58c56ca7
self-hosted: implement Decl lookup
...
* Take advantage of coercing anonymous struct literals to struct types.
* Reworks Module to favor Zig source as the primary use case.
Breaks ZIR compilation, which will have to be restored in a future commit.
* Decl uses src_index rather then src, pointing to an AST Decl node
index, or ZIR Module Decl index, rather than a byte offset.
* ZIR instructions have an `analyzed_inst` field instead of Module
having a hash table.
* Module.Fn loses the `fn_type` field since it is redundant with
its `owner_decl` `TypedValue` type.
* Implement Type and Value copying. A ZIR Const instruction's TypedValue
is copied to the Decl arena during analysis, which allows freeing the
ZIR text instructions post-analysis.
* Don't flush the ELF file if there are compilation errors.
* Function return types allow arbitrarily complex expressions.
* AST->ZIR for function calls and return statements.
2020-06-18 17:12:56 -04:00
Andrew Kelley
b4eac0414a
stage2: hook up Zig AST to ZIR
...
* Introduce the concept of anonymous Decls
* Primitive Hello, World with inline asm works
* There is still an unsolved problem of how to manage ZIR instructions
memory when generating from AST. Currently it leaks.
2020-06-18 17:12:56 -04:00
Andrew Kelley
47090d234e
stage2: add passing test for compile error in unreferenced cycle
2020-06-08 15:16:40 -04:00
Andrew Kelley
9ea4965ceb
self-hosted: remove deleted Decls from failed_decls
2020-06-08 15:16:40 -04:00
Andrew Kelley
91930a4ff0
stage2: fix not re-loading source file for updates after errors
2020-06-08 15:16:40 -04:00
Andrew Kelley
cf654b52d6
stage2: -femit-zir respects decl names and supports cycles
2020-06-08 15:16:40 -04:00
Andrew Kelley
6524a64bda
stage2: fix referencing decls which appear later in the file
2020-06-02 17:43:51 -04:00