462 Commits

Author SHA1 Message Date
Andrew Kelley
fe87bae7e3 frontend: fix handling of special builtin module
it's allocated differently and imported differently
2024-01-01 17:51:20 -07:00
Andrew Kelley
c49957dbe8 fix a round of compile errors caused by this branch 2024-01-01 17:51:19 -07:00
Andrew Kelley
bc4d2b646d compiler: update references to target 2024-01-01 17:51:19 -07:00
Andrew Kelley
f5ddef1e45 update references to module (to be renamed to zcu) 2024-01-01 17:51:19 -07:00
Andrew Kelley
9a48a5ab07 compiler: update references to single_threaded 2024-01-01 17:51:19 -07:00
Jacob Young
50993a8f08 x86_64: implement more operations on vectors with 1-bit elements 2023-12-04 01:29:07 -05:00
Jacob Young
014833b61f x86_64: implement more compliant vectors 2023-12-03 10:22:06 -05:00
Jacob Young
bf5ab54510 test: test with -fstrip and fix failures
Closes #17513
2023-12-01 04:34:50 +00:00
Meghan Denny
2549de80b2 move Module.Decl.Index and Module.Namespace.Index to InternPool 2023-11-26 02:24:40 -05:00
Techatrix
18608223ef convert toType and toValue to Type.fromInterned and Value.fromInterned 2023-11-25 04:09:53 -05:00
mlugg
b355893438
compiler: correct unnecessary uses of 'var' 2023-11-19 11:11:49 +00:00
Jacob Young
80b73e3e8f x86_64: resolve tlv references on first use and spill to the stack
This avoids any arbitrary memory operand possibly clobbering rax and
sometime rdi with no warning.
2023-11-12 18:12:41 -05:00
Jakub Konka
575c29e5c4 elf: set symbol flags such as needs_zig_got in ZigObject 2023-11-12 18:12:41 -05:00
Jakub Konka
f24ceec35a
Merge pull request #17844 from ziglang/elf-object
elf: handle emitting relocatables and static libraries - humble beginnings
2023-11-04 20:58:15 +01:00
Jakub Konka
ccb2afacc0 elf: postpone creation of .got.zig entry until code emit 2023-11-04 09:11:29 +01:00
Jakub Konka
8055f68765 elf: make sure we never emit .got.zig relocs when linking object files 2023-11-04 09:10:23 +01:00
Jacob Young
509be7cf1f x86_64: fix std test failures 2023-11-03 23:18:21 -04:00
Jakub Konka
9bdbb6312f elf: move incremental codegen bits into ZigObject.zig 2023-10-30 19:09:13 +01:00
Jakub Konka
b2e847a41a elf: rename ZigModule to ZigObject 2023-10-30 19:09:13 +01:00
Jakub Konka
324a93e673 coff: implement enough of extern handling to pass comptime export tests 2023-10-30 12:44:50 +01:00
Jakub Konka
2e690f5c74 macho: implement enough of extern handling to pass comptime export tests 2023-10-30 00:09:32 +01:00
Jakub Konka
2be1250f24 x86_64: no more load/lea_symbol weirdness 2023-10-28 03:48:18 -04:00
Jakub Konka
0d00b7c585 elf: set needs_got on generated extern vars 2023-10-28 03:48:18 -04:00
Jakub Konka
9a1fbb2705 x86_64: rename load/lea_memory to load/lea_symbol 2023-10-28 03:48:18 -04:00
Jakub Konka
a6a10d9c2b x86_64: do not hardcode memory passed by Elf linker 2023-10-28 03:48:18 -04:00
Jacob Young
b55377a5ab x86_64: pass more tests
* 128-bit integer multiplication with overflow
 * more instruction encodings used by std inline asm
 * implement the `try_ptr` air instruction
 * follow correct stack frame abi
 * enable full panic handler
 * enable stack traces
2023-10-25 04:28:30 -04:00
mlugg
20bb81166f
InternPool: remove runtime_value representation
The main goal of this commit is to remove the `runtime_value` field from
`InternPool.Key` (and its associated representation), but there are a
few dominos. Specifically, this mostly eliminates the "maybe runtime"
concept from value resolution in Sema: so some resolution functions like
`resolveMaybeUndefValAllowVariablesMaybeRuntime` are gone. This required
a small change to struct/union/array initializers, to no longer
use `runtime_value` if a field was a `variable` - I'm not convinced this
case was even reachable, as `variable` should only ever exist as the
trivial value of a global runtime `var` decl.

Now, the only case in which a `Sema.resolveMaybeUndefVal`-esque function
can return the `variable` key is `resolveMaybeUndefValAllowVariables`,
which is directly called from `Sema.resolveInstValueAllowVariables`
(previously `Sema.resolveInstValue`), which is only used for resolving
the value of a Decl from `Module.semaDecl`.

While changing these functions, I also slightly reordered and
restructured some of them, and updated their doc comments.
2023-10-24 14:28:33 +01:00
Andrew Kelley
94d61ce964
Merge pull request #17651 from Vexu/error-limit
Make distinct error limit configurable (attempt #2)
2023-10-23 03:19:03 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadbe29294f2bf3153a27beebd64377566.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab63865592bb084feb271cd4e4b0357e, reversing
changes made to 5f92b070bf284f1493b1b5d433dd3adde2f46727.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Jacob Young
0c99ba1eab
Merge pull request #17637 from jacobly0/x86_64-test-std
x86_64: start to enable `test-std` and `test-compiler-rt` testing
2023-10-22 08:06:47 -04:00
Veikka Tuominen
9d9e22e716 remove uses of non-configurable err_int 2023-10-22 14:29:26 +03:00
Jacob Young
c4fcf0e22a codegen: implement lowering aligned anon decls 2023-10-21 21:38:41 -04:00
Andrew Kelley
7bab406c79 InternPool: store alignment of anon decls
Commit 5393e56500d499753dbc39704c0161b47d1e4d5c has a flaw pointed out
by @mlugg: the `ty` field of pointer values changes when comptime values
are pointer-casted. This commit introduces a new encoding which
additionally stores the "original pointer type" which is used to store
the alignment of the anonymous decl, and potentially other information
in the future such as section and pointer address space. However, this
new encoding is only used when the original pointer type differs from
the casted pointer type in a meaningful way.

I was able to make the LLVM backend and the C backend lower anonymous
decls with the appropriate alignment, however I will need some help
figuring out how to do this for the backends that lower anonymous decls
via src/codegen.zig and the wasm backend.
2023-10-21 21:38:41 -04:00
Jacob Young
c880644d92 x86_64: disable difficult std tests and hack around more zero-bit types 2023-10-21 10:55:41 -04:00
Jakub Konka
6993b3e23e codegen: refactor .actual_got into .extern_got 2023-10-16 19:33:06 +02:00
Jakub Konka
7b2cbcf0fe codegen+elf: check if extern is a variable ref 2023-10-16 19:33:06 +02:00
Jakub Konka
45197ea7ad codegen+elf: lower imported data refs 2023-10-16 19:33:06 +02:00
Jakub Konka
17635e4f2a x86_64: add -fPIC support targeting ELF 2023-10-16 19:33:06 +02:00
Jakub Konka
7be983ac92 elf: create new synthetic section ZigGotSection 2023-10-16 19:33:05 +02:00
Jacob Young
b4427bc300 plan9: refactor debug info
The main goal is to stop depending on `emit.lower.target`.
2023-10-05 00:19:25 -04:00
Jakub Konka
0134e5d2a1 codegen: separate getAnonDeclVAddr into lowerAnonDecl and the former
Implement the stub for Elf.

I believe that separating the concerns, namely, having an interface
function that is responsible for signalling the linker to lower
the anon decl only, and a separate function to obtain the decl's
vaddr is preferable since it allows us to handle codegen errors
in a simpler way.
2023-10-03 12:49:12 -07:00
Andrew Kelley
0483b4a512 link: stub out getAnonDeclVAddr 2023-10-03 12:12:51 -07:00
Andrew Kelley
c0b5512544 compiler: start handling anonymous decls differently
Instead of explicitly creating a `Module.Decl` object for each anonymous
declaration, each `InternPool.Index` value is implicitly understood to
be an anonymous declaration when encountered by backend codegen.

The memory management strategy for these anonymous decls then becomes to
garbage collect them along with standard InternPool garbage.

In the interest of a smooth transition, this commit only implements this
new scheme for string literals and leaves all the previous mechanisms in
place.
2023-10-03 12:12:50 -07:00
kcbanner
9f4649b197 codegen/sema: handle unions with unknown tags in more places 2023-09-23 14:34:01 -04:00
kcbanner
f2a24b48e1 sema: rework the comptime representation of comptime unions
When the tag is not known, it's set to `.none`. In this case, the value is either an
array of bytes (for extern unions) or an integer (for packed unions).
2023-09-23 13:05:04 -04:00
kcbanner
2fddd767ba sema: add support for unions in readFromMemory and writeToMemory 2023-09-23 13:04:56 -04:00
Andrew Kelley
55bc8a7fa9 compiler: fix compilation for 32-bit targets 2023-09-21 15:27:25 -07:00
Andrew Kelley
accd5701c2 compiler: move struct types into InternPool proper
Structs were previously using `SegmentedList` to be given indexes, but
were not actually backed by the InternPool arrays.

After this, the only remaining uses of `SegmentedList` in the compiler
are `Module.Decl` and `Module.Namespace`. Once those last two are
migrated to become backed by InternPool arrays as well, we can introduce
state serialization via writing these arrays to disk all at once.

Unfortunately there are a lot of source code locations that touch the
struct type API, so this commit is still work-in-progress. Once I get it
compiling and passing the test suite, I can provide some interesting
data points such as how it affected the InternPool memory size and
performance comparison against master branch.

I also couldn't resist migrating over a bunch of alignment API over to
use the log2 Alignment type rather than a mismash of u32 and u64 byte
units with 0 meaning something implicitly different and special at every
location. Turns out you can do all the math you need directly on the
log2 representation of alignments.
2023-09-21 14:48:40 -07:00
Jakub Konka
ce88df497c elf: do not store Symbol's index in Symbol 2023-09-13 21:51:43 +02:00