Commit Graph

3222 Commits

Author SHA1 Message Date
Jakub Konka
e8e305b67c Re-enable multiple wasm32 vector tests
Fixes #5339
2021-06-09 23:54:23 -04:00
Lee Cannon
629e2e7844
Add a logging allocator that uses std.log (#8511) 2021-06-09 21:42:07 +03:00
Lee Cannon
50822530d3
Provide method to set logging level per scope (#8584) 2021-06-09 12:23:45 +03:00
jacob gw
b57ac48773 stage2: compile error for ambiguous decl refrences
std: fix compile errors from this change. This is a stage1 bug.
2021-06-08 18:13:12 -04:00
Andrew Kelley
ccfa168284
Merge pull request #9030 from Vexu/stage2
Stage2: implement comptime variables
2021-06-08 14:16:57 -04:00
Matthew Borkowski
9ac6d28614 stage1: make @truncate to an integer type of different sign an error at comptime too 2021-06-08 20:58:30 +03:00
Veikka Tuominen
d41a5105cd stage2: fix repeat_inline skipping first instruction in block
Co-authored-by: Andrew Kelley <andrew@ziglang.org>
2021-06-08 10:15:34 +03:00
Jakub Konka
b0ee911c23 wasi: always grant fd_readdir right
Since v0.23 release of Wasmtime, if we want to iterate a directory
Y then directory Y needed to have been granted `fd_readdir` right.
However, it is now also required for directory X to carry `fd_readdir`
right, and so on, up-chain all the way until we reach the preopen
(which possesses all rights by default).

This caused problems for us since our libstd implementation is more
fine-grained and allowed for parent dirs not to carry the right while
allow for iterating on its children. My proposal here is to always
grant `fd_readdir` right as part of
`std.fs.Dir.OpenDirOptions.access_sub_paths`. This seems to be the
approach taken by Rust also, plus we should be justified to take this
approach since WASI is experimental and snapshot1 will be discontinued
eventually and replaced with a new approach to access management
that will require a complete rewrite of our libstd anyhow.
2021-06-08 05:48:33 +02:00
Veikka Tuominen
7efd7bc3b8 stage2: implement comptime variables 2021-06-07 22:15:56 +03:00
Evan Haas
fa6546ba74 translate-c: properly handle enums used as boolean expressions 2021-06-07 15:51:42 +03:00
LemonBoy
fc8791c133 stage1: Allow array-like initialization for tuple types
This small change makes working with tuple types much easier, allowing
the use of anonymous (eg. obtained with meta.ArgsTuple) tuples in more
places without the need for specifying each (quoted!) field name in the
initializer.
2021-06-06 21:21:42 -04:00
LemonBoy
616c82e446 Revert "tests: disable i386-linux-gnu -lc target due to CI failures"
This reverts commit 97a2f4e7ae.
2021-06-06 18:04:16 -07:00
Michael Dusan
0bda8435e0 test: re-enable dragonfly tests
Tests with LLVM assertions enabled are no longer failing.

closes #3563
2021-06-05 22:08:36 -04:00
Martin Wickham
fc9430f567 Breaking hash map changes for 0.8.0
- hash/eql functions moved into a Context object
- *Context functions pass an explicit context
- *Adapted functions pass specialized keys and contexts
- new getPtr() function returns a pointer to value
- remove functions renamed to fetchRemove
- new remove functions return bool
- removeAssertDiscard deleted, use assert(remove(...)) instead
- Keys and values are stored in separate arrays
- Entry is now {*K, *V}, the new KV is {K, V}
- BufSet/BufMap functions renamed to match other set/map types
- fixed iterating-while-modifying bug in src/link/C.zig
2021-06-03 17:02:16 -05:00
Veikka Tuominen
c6a0a4e728 translate-c: support designated initializers in macros 2021-06-01 23:40:43 -04:00
Isaac Freund
608bc1cbd5
stage2: disallow 1.e9 and 0x1.p9 as float literals
Instead require `1e9` and `0x1p9`, disallowing the trailing dot.

This change to the grammar is consistent with forbidding `1.` and `0x1.`
as float literals and ensures there is only one way to do things here.
2021-05-31 19:51:11 +00:00
Andrew Kelley
c12704a339
Merge pull request #8918 from ziglang/stage1-tokenizer
stage1: rework tokenizer to match stage2
2021-05-28 21:54:01 -04:00
Andrew Kelley
3f5ca3920a AstGen: properly restore previous state after temporary changes
Before this, if a compile error occurred, it would cause the previous
value for e.g. the function scope to not get reset. If the AstGen
process continued, it would result in a violation of the data
guarantees that it relies on.

This commit takes advantage of defer to ensure the previous value is
always reset, even in the case of an error.

Closes #8920
2021-05-28 17:29:56 -07:00
Andrew Kelley
97a2f4e7ae tests: disable i386-linux-gnu -lc target due to CI failures
See #8930
2021-05-28 16:31:09 -07:00
LemonBoy
d3fb9f9532 stage1: Fix for atomicrmw xchg on fp types
Bitcast the pointer and operands to integer types having the same size,
working around LLVM inability to lower a LL/SC operation when the
operands have floating-point types (and are reasonably sized).

Closes #4457
2021-05-28 19:18:42 -04:00
Andrew Kelley
52b3daa90e stage1: get test-compile-errors passing again 2021-05-28 14:19:08 -07:00
Andrew Kelley
2a990d6966 stage1: rework tokenizer to match stage2
* Extracts AstGen logic from ir.cpp into astgen.cpp. Reduces the
   largest file of stage1 from 33,551 lines to 25,510.
 * tokenizer: rework it completely to match the stage2 tokenizer logic.
   They can now be maintained together; when one is changed, the other
   can be changed in the same way.
   - Each token now takes up 13 bytes instead of 64 bytes. The tokenizer
     does not parse char literals, string literals, integer literals,
     etc into meaningful data. Instead, that happens during parsing or
     astgen.
   - no longer store line offsets. Error messages scan source
     files to find the line/column as needed (same as stage2).
   - main loop: instead of checking the loop, handle a null byte
     explicitly in the switch statements. This is a nice improvement
     that we may want to backport to stage2.
   - delete some dead tokens, artifacts of past syntax that no longer
     exists.
 * Parser: fix a TODO by parsing builtin functions as tokens rather than
   `@` as a separate token. This is how stage2 does it.
 * Remove some debugging infrastructure. These will need to be redone,
   if at all, as the code migrates to match stage2.
   - remove the ast_render code.
   - remove the IR debugging stuff
   - remove teh token printing code
2021-05-28 12:58:40 -07:00
Luuk de Gram
5cbe930e36
wasm: Add stage2 tests for error unions 2021-05-28 12:58:17 +02:00
xavier
32154fbf0d add a standalone for zig as a c/c++ compiler 2021-05-25 00:42:31 +02:00
xavier
7e4f28fac9 standalone tests may now test cross targets and build modes. 2021-05-25 00:19:23 +02:00
Andrew Kelley
55811d8dac stage2: introduce clangAssemblerSupportsMcpuArg
Clang has a completely inconsistent CLI for its integrated assembler for
each target architecture. For x86_64, for example, it does not accept
an -mcpu parameter, and emits "warning: unused parameter". However, for
ARM, -mcpu is needed in order to properly lower assembly to machine code
instructions (see new standalone test case provided thanks to @g-w1).

This is a compromise between
b8f85a805b and
afb9f695b1.
2021-05-23 21:51:10 -07:00
Michael Dusan
0f26120377 overhaul elf csu (c-runtime startup) logic
- more support for linux, android, freebsd, netbsd, openbsd, dragonfly
- centralize musl utils; musl logic is no longer intertwined with csu
- fix musl compilation to build crti/crtn for full archs list
- fix openbsd to support `zig build-lib -dynamic`
- initial dragonfly linking success (with a warning)

ancillary:

- fix emutls (openbsd) tests to use `try`
2021-05-23 15:38:57 -04:00
Evan Haas
d321a4b765 translate-c: Translate FnDecl's that appear within functions 2021-05-23 15:42:36 +03:00
Andrew Kelley
1c636e2564
Merge pull request #8844 from ifreund/inline
Support inline keyword as well as callconv(.Inline)
2021-05-22 20:56:30 -04:00
jacob gw
9baf891772 stage2: astgen error for return or try in defer block 2021-05-22 20:54:14 -04:00
Jakub Konka
2b0d322ea0 zld: permit system static libs
This commits permits passing in static archives using the system
lib flag `-la`. With this commit, `zig ld` will now look firstly for
a dynamic library (which always takes precedence), and will fall back
on `liba.a` if the dylib is not found. The static archive is searched
for in the system lib search dirs like the dylibs.
2021-05-22 16:12:45 +02:00
Andrew Kelley
0267abfe9b
Merge pull request #8847 from Luukdegram/wasm-struct-switch
stage2: wasm - Structs and switch support
2021-05-20 18:55:49 -04:00
Isaac Freund
563ea60a86
translate-c: use inline keyword instead of callconv(.Inline) 2021-05-20 21:59:46 +02:00
Andrew Kelley
df56bf94a2
Merge pull request #8789 from Luukdegram/wasm-enum
stage2: wasm backend - Enums
2021-05-20 14:03:54 -04:00
Luuk de Gram
0ac56e7f3a
Add test cases for switches 2021-05-20 19:59:37 +02:00
Luuk de Gram
87a9c6946d
wasm backend: implement multi_value for WValue
This allows us to differentiate between regular locals and variables that create multiple locals
on the stack such as optionals and structs.
Now `struct_a = struct_b;` works and only updates a reference, rather than update all local's values.

Also created more test cases to test against this.
2021-05-20 09:25:02 +02:00
Evan Haas
1273bc277f translate-c: add support for __cleanup__ attribute
Use a `defer` statement to implement the C __cleanup__ attribute.

See https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html
2021-05-19 12:12:18 +03:00
Luuk de Gram
6962647862
Do not create a local for the struct itself + test cases 2021-05-19 10:37:44 +02:00
Luuk de Gram
141a0cbb5a
Explicit return & more complex wasm enum test
- When returning within a block, we must use an explicit return opcode. For now always emit the opcode when calling return, rather than using implicit return statements.
- Also added a more comprehensive test case to test for enum values using conditions
2021-05-19 10:35:45 +02:00
Luuk de Gram
9ddede2950
Add enum test case for wasm backend 2021-05-19 08:59:11 +02:00
Andrew Kelley
2c12f5f55b stage2 tests: fix missing 'pub' in one of the test cases 2021-05-18 12:53:23 -07:00
Andrew Kelley
a9cd9b021b Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
I want the updated Drone CI stuff to get the CI green.
2021-05-18 12:37:03 -07:00
Andrew Kelley
ab8f8465a3 stage2: fix deletion of Decls that get re-referenced
When scanDecls happens, we create stub Decl objects that
have not been semantically analyzed. When they get referenced,
they get semantically analyzed.

Before this commit, when they got unreferenced, they were completely
deleted, including deleted from the containing Namespace.

However, if the update did not cause the containing Namespace to get
deleted, for example, if `std.builtin.ExportOptions` is no longer
referenced, but `std.builtin` is still referenced, and then `ExportOptions`
gets referenced again, the Namespace would be incorrectly missing the
Decl, so we get an incorrect "no such member" error.

The solution is to, when dealing with a no longer referenced Decl
objects during an update, clear them to the state they would be in
on a fresh scanDecl, rather than completely deleting them.
2021-05-18 12:35:36 -07:00
Jakub Konka
1dac5f5214 zld: parse dylibs as positionals
* add preliminary rpath support
* enable shared_library test on x86_64 macOS
2021-05-18 09:28:00 +02:00
Evan Haas
35c694d614 translate-c: Demote initialization of opaque types
This fixes a segfault in translate-c that would previously occur when
initializing structs with unnamed bitfields, due to a failed assertion in
`transInitListExprRecord`. Unnamed bitfields do not have initializers,
so `transInitListExprRecord` erroneously assumes that `init_count` equals
the number of fields in the record.

Since attempting to initialize an opaque type is a syntax error in Zig,
we can just demote any attempts to initialize them.
2021-05-18 09:04:19 +03:00
Andrew Kelley
615d45da77 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * src/codegen/spirv.zig
 * src/link/SpirV.zig

We're going to want to improve the stage2 test harness to print
the source file name when a compile error occurs otherwise std lib
contributors are going to see some confusing CI failures when they cause
stage2 AstGen compile errors.
2021-05-17 19:30:38 -07:00
Andrew Kelley
1d3f76bbda stage2: skip recursion test on some hosts
In order for this test to pass, the host linking/start code needs to
support explicitly setting the stack size. Zig defaults to 16 MiB stack
size, which is enough to pass the test in Debug builds, however, most
operating systems do not honor the stack size we request for and give a
smaller amount.

Eventually the goal is to pass this test on all hosts.
2021-05-17 19:14:13 -07:00
Andrew Kelley
910f67f77b behavior tests: re-enable commented out test
Not sure why it was failing, also not sure why it started passing again
2021-05-17 16:09:20 -07:00
Andrew Kelley
8a7a07f30d stage2: test cases take advantage of pub fn main support 2021-05-17 16:09:20 -07:00
Andrew Kelley
8cfa231104 update langref, compile-error tests, safety tests
for the std.builtin re-arranging
2021-05-17 15:25:27 -07:00
Andrew Kelley
f41892f736 std: @import("builtin").StackTrace -> std.builtin.StackTrace 2021-05-17 14:36:51 -07:00
joachimschmidt557
65cee0b3fd stage2 ARM: correct spilling in genArmMul as well 2021-05-17 17:18:01 -04:00
Andrew Kelley
ae04ec776d Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Need that _main -> main improvement
2021-05-16 00:00:36 -07:00
Jakub Konka
6461b95163 macho: fix DWARF in dSYM and sym naming more consistent
* Advance line and PC prior to ending sequence in debug line program
  for a fn_decl. This is equivalent to closing scope in the debugger
  and without it, the debugger will not map source-to-address info
  as a result will not print the source when breaking at a symbol.
* Fix debug aranges sentinels to be of the size as the actual tuple
  descriptor (assuming segment selector to be ommitted). In summary,
  the sentinels were 32bit 0s, whereas they ought to be 64bit 0s.
* Make naming of symbols in the binary more consistent by prefixing
  each symbol name with an underscore '_'.
2021-05-16 08:12:29 +02:00
Andrew Kelley
597082adf4 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * build.zig
 * src/Compilation.zig
 * src/codegen/spirv/spec.zig
 * src/link/SpirV.zig
 * test/stage2/darwin.zig
   - this one might be problematic; start.zig looks for `main` in the
     root source file, not `_main`. Not sure why there is an underscore
     there in master branch.
2021-05-15 21:44:38 -07:00
Andrew Kelley
07606d12da stage2: remove SPU Mark II backend
As it stands, the backend is incomplete, and there is no active contributor,
making it dead weight.

However, anyone is free to resurrect this backend at any time.
2021-05-15 21:25:42 -07:00
Andrew Kelley
7cd94d2123 stage2: omit Decl compile errors from failed AstGen files
Just like when new parse errors occur during an update, when new AstGen
errors occur during an update, we do not reveal compile errors for Decl
objects which are inside of a newly failed File. Once the File passes
AstGen successfully, it will be compared with the previously succeeded
ZIR and the saved Decl compile errors will be handled properly.
2021-05-15 21:20:06 -07:00
Andrew Kelley
dc036f5b6f codegen: implement const value rendering for ints <= 64 bits 2021-05-15 21:00:15 -07:00
Evan Haas
36da8d02b5 translate-c: translate global (file scope) assembly 2021-05-15 11:53:01 +03:00
Andrew Kelley
b4692c9a78 stage2: improve Decl dependency management
* Do not report export collision errors until the very end, because it
   is possible, during an update, for a new export to be added before an
   old one is semantically analyzed to be deleted. In such a case there
   should be no compile error.
   - Likewise we defer emitting exports until the end when we know for
     sure what will happen.
 * Sema: Fix not adding a Decl dependency on imported files.
 * Sema: Properly add Decl dependencies for all identifier and namespace
   lookups.
 * After semantic analysis for a Decl, if it is still marked as
   `in_progress`, change it to `dependency_failure` because if the Decl
   itself failed, it would have already been changed during the call to
   add the compile error.
2021-05-14 17:41:22 -07:00
LemonBoy
a52e472307 stage1: Widen non byte-sized atomic loads/stores
Checking if the size is a power of two is not enough, should also check
if it's a multiple of 8.

Closes #7976
2021-05-14 15:16:24 -04:00
Jakub Konka
00ebbe6df2 macho: require _main as global export in self-hosted
Clean up type and description flags generation for exports
in self-hosted MachO backend.
2021-05-14 13:08:56 +02:00
Jakub Konka
8eea5eddf7 macho: fix bug with symbol growth and realloc 2021-05-14 11:02:43 +02:00
Andrew Kelley
9958652d92 stage2: update test cases to improved source locations 2021-05-14 00:08:29 -07:00
Andrew Kelley
8344a50e1c AstGen: add compile error for decl name conflicts
* Remove the ability for GenZir parent Scope to be null. Now there is a
   Top Scope at the top.
 * Introduce Scope.Namespace to contain a table of decl names in order
   to emit a compile error for name conflicts.
 * Fix use of invalid memory when reporting compile errors by
   duplicating decl names into a temporary heap allocated buffer.
 * Fix memory leak in while and for loops, not cleaning up their
   labeled_breaks and store_to_block_ptr_list arrays.
 * Fix stage2 test cases because now the source location of redundant
   comptime keyword compile errors is improved.
 * Implement compile error for local variable shadowing declaration.
2021-05-13 23:51:22 -07:00
Andrew Kelley
134853f106 stage2: fix tests expected values 2021-05-13 20:44:34 -07:00
Jakub Konka
402264ab0e Add experimental Darling support for cross testing macOS
* for cross testing stage2 tests, we use `darling shell` command
  since the path to the tested binary is relative to cwd
* for the `zig test` command, we simply use `darling` since the
  path to the binary is absolute
2021-05-13 20:31:33 +02:00
Andrew Kelley
b109daacdd stage2: fix test cases to add pub on exported _start fn
This way the start code respects them.
2021-05-12 23:17:24 -07:00
Andrew Kelley
c9cc09a3bf Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * lib/std/os/linux.zig
 * lib/std/os/windows/bits.zig
 * src/Module.zig
 * src/Sema.zig
 * test/stage2/test.zig

Mainly I wanted Jakub's new macOS code for respecting stack size, since
we now depend on it for debug builds able to pass one of the test cases
for recursive comptime function calls with `@setEvalBranchQuota`.

The conflicts were all trivial.
2021-05-12 16:41:20 -07:00
Jakub Konka
53acb54fad
Bump zig-bootstrap and wasmtime versions in linux CI (#8738)
* Bump zig-bootstrap and wasmtime versions in linux CI

* Revert wasm stage2 test fixup; point to issue
2021-05-12 09:56:55 +02:00
Andrew Kelley
1ab1a96f87 stage2: improve Decl lifetime management
* Compilation: iteration over the deletion_set only tries to delete the
   first one, relying on Decl destroy to remove itself from the deletion
   set.
 * link: `freeDecl` now has to handle the possibility of freeing a Decl
   that was never called with `allocateDeclIndexes`.
 * `deleteDecl` recursively iterates over a Decl's Namespace sub-Decl
   objects and calls `deleteDecl` on them.
   - Prevents Decl objects from being destroyed when they are still in
     `deletion_set`.
 * Sema: fix cleanup of anonymous Decl objects when an error occurs
   during semantic analysis.
 * tests: update test cases for fully qualified names
2021-05-11 22:12:36 -07:00
Andrew Kelley
5d9fc11d18 stage2: update tests now that structs have fully qualified names 2021-05-11 14:51:54 -07:00
Andrew Kelley
bcf15e39e2 stage2: add owns_tv flag to Module.Decl
Decl objects need to know whether they are the owner of the Type/Value
associated with them, in order to decide whether to destroy the
associated Namespace, Fn, or Var when cleaning up.
2021-05-11 14:17:52 -07:00
LemonBoy
93f48189f1 test: Enable i386-linux-gnu test
This is needed to catch any possible problem with executables linking to
32bit glibc.
2021-05-11 12:33:48 +02:00
xackus
8f8efcdd6e translate-c: fix typedefs with multiple names 2021-05-10 21:59:42 +03:00
joachimschmidt557
f2a3368891 stage2 ARM: Add spill registers test 2021-05-09 08:48:58 +02:00
Andrew Kelley
b88d381dec
Merge pull request #8474 from gracefuu/grace/encode-instruction
stage2 x86_64: encoding helpers, fix bugs
2021-05-09 01:36:51 -04:00
Andrew Kelley
5619ce2406 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * doc/langref.html.in
 * lib/std/enums.zig
 * lib/std/fmt.zig
 * lib/std/hash/auto_hash.zig
 * lib/std/math.zig
 * lib/std/mem.zig
 * lib/std/meta.zig
 * test/behavior/alignof.zig
 * test/behavior/bitcast.zig
 * test/behavior/bugs/1421.zig
 * test/behavior/cast.zig
 * test/behavior/ptrcast.zig
 * test/behavior/type_info.zig
 * test/behavior/vector.zig

Master branch added `try` to a bunch of testing function calls, and some
lines also had changed how to refer to the native architecture and other
`@import("builtin")` stuff.
2021-05-08 14:45:21 -07:00
Andrew Kelley
b6bb0ee1ac Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
Conflicts:
 * lib/std/os/linux/tls.zig
 * test/behavior/align.zig
 * test/behavior/atomics.zig
 * test/behavior/vector.zig
2021-05-08 10:53:22 -07:00
Veikka Tuominen
7437c47d55 tests: work around miscompilation 2021-05-08 15:18:13 +03:00
Veikka Tuominen
0a38f61d58 update usage of std.testing in behavior and standalone tests 2021-05-08 15:15:30 +03:00
Andrew Kelley
28353b3159 stage2: fix struct inits not getting fields resolved 2021-05-07 22:16:15 -07:00
Andrew Kelley
81d5104e22 stage2: implement global variables
* Sema: implement global variables
   - Improved global constants to stop needlessly creating a Var
     structure; they can just store the value directly.
   - This required making memory management a bit more sophisticated to
     detect when a Decl owns the Namespace associated with it, for the
     purposes of deinitialization.
 * Decl.name and Namespace decl table keys no longer directly
   reference ZIR; instead they have heap-duped names, so that deleted
   decls, which no longer have any ZIR to reference for their names, can
   be removed from the parent Namespace table.
   - In the future I would like to explore going a different direction
     with this, where the strings would still point to the ZIR however
     they would be removed from their owner Namespace objects during the
     update detection. The design principle here is that the existence
     of incremental compilation as a feature should not incur any cost
     for the use case when it is not used. In this example Decl names
     could simply point to ZIR string table memory, and it is only
     because of incremental compilation that we duplicate their names.
 * AstGen: implement threadlocal variables
 * CLI: call cleanExit after building a compilation so that in release
   modes we don't bother freeing memory or closing file descriptors,
   allowing the OS to do it more efficiently.
 * Avoid calling `freeDecl` in the linker for unreferenced Decl objects.
 * Fix CBE test case expecting the compile error to point to the wrong
   column.
2021-05-07 18:52:11 -07:00
Andrew Kelley
3acd98fa34 stage2: CBE tests pub export instead of export main
This is needed so that start code can avoid redundantly trying to export
a main function for libc to call.
2021-05-06 17:51:09 -07:00
Andrew Kelley
7dd33d4316 stage2: fix compile errors in test harness 2021-05-06 17:48:38 -07:00
Andrew Kelley
530e67cb86
Merge pull request #8683 from LemonBoy/thumblinux
Initial bringup for Linux/Thumb2
2021-05-06 12:50:34 -04:00
Andrew Kelley
5d7f2697de stage2: add zig changelist debug command
and implement the first pass at mechanism to map old ZIR to new ZIR.
2021-05-05 13:16:14 -07:00
Jakub Konka
ad33e34836 tests: re-enable reduce behavior tests for wasm32 2021-05-05 21:26:50 +02:00
Andrew Kelley
1f0fd64302 stage2: test coverage for inline asm return type not type 2021-05-04 14:23:53 -07:00
LemonBoy
afbcb6209d std: Initial bringup for Linux on Thumb2
There are some small problems here and there, mostly due to the pointers
having the lsb set and disrupting the fn alignment tests and the
`@FrameSize` implementation.
2021-05-04 18:52:53 +02:00
LemonBoy
389d1177a5 stage1: Fix LLVM error in inline asm invocation
Pointer types need an extra indirection layer during the generation of
the function prototype for inline asm blocks.

Closes #3606
2021-05-04 18:43:31 +02:00
Andrew Kelley
4307436b99 move behavior tests from test/stage1/ to test/
And fix test cases to make them pass. This is in preparation for
starting to pass behavior tests with self-hosted.
2021-04-29 15:54:04 -07:00
Andrew Kelley
5a02c938da update behavior tests with respect to new builtin pkg 2021-04-29 15:18:40 -07:00
Andrew Kelley
eb53680bce tests: prepare behavior tests for stage2 2021-04-29 14:51:21 -07:00
jacob gw
2354cbafdb stage2: implement #8364 2021-04-28 19:54:04 -04:00
Andrew Kelley
df24ce52b1 Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgen
In particular I wanted to take advantage of the new hex float parsing
code.
2021-04-28 14:57:38 -07:00
joachimschmidt557
bc06e19828 stage2 riscv64: cleanup code and add tests 2021-04-28 07:20:45 +02:00
LemonBoy
82f1d592fa stage1: Use correct alignment for asyncCall frame 2021-04-25 20:41:49 +02:00
LemonBoy
ae15022406 translate-c: Fix casting of function pointers
The @ptrCast(X, @alignCast(@alignOf(T), Y)) pattern is only correct if T
is not a function type or a pointer, in that case the @alignOf refers to
the pointer itself and not to the pointee type.
2021-04-25 16:50:41 +02:00
LemonBoy
50a8124f45 stage1: Change how the Frame alignment is computed
The code would previously assume every function would start at addresses
being multiples of 16, this is not true beside some specific cases.
Moreover LLVM picks different alignment values depending on whether it's
trying to generate dense or fast code.

Let's use the minimum guaranteed alignment as base value, computed
according to how big the opcodes are.

The alignment of function pointers is always 1, a safe value that won't
cause any error at runtime. Note that this was already the case before
this commit, here we're making this choice explicit.

Let the 'alignment' field for TypeInfo of fn types reflect the ABI
alignment used by the compiler, make this field behave similarly to the
'alignment' one for pointers.
2021-04-25 16:40:41 +02:00