Commit Graph

8469 Commits

Author SHA1 Message Date
Koakuma 47b136e3b3 stage2: Add SPARC function alignment
This is based on @kubkon's suggestion.
2022-04-14 22:18:06 +07:00
Koakuma a6ce2fc3dc linker: ELF: Add page sizes for ppc64le and sparcv9 2022-04-14 22:18:06 +07:00
Koakuma b916ba18b6 stage2: sparcv9: Fix Tcc encoding 2022-04-14 22:18:06 +07:00
Koakuma dcb12a7941 stage2: sparcv9: Use regular structs to encode instructions
Currently packed structs still has endian-dependent behavior, so it results
in code that is not portable across platforms (see also issue 10113).
2022-04-14 22:18:06 +07:00
Koakuma 1467590e40 stage2: sparcv9: Implement enough instruction to compile simple exes 2022-04-14 22:18:06 +07:00
Koakuma 1f63afa7c9 stage2: sparcv9: Register the backend in stdlib & driver 2022-04-14 22:18:06 +07:00
Koakuma cfd389f927 stage2: sparcv9: zig fmt 2022-04-14 22:18:06 +07:00
Flandre Scarlet ab2ea9fb09 stage2: sparcv9: Test failure error logging 2022-04-14 22:18:06 +07:00
Koakuma 7051970ad7 stage2: sparcv9: implement basic instruction lowering 2022-04-14 22:18:06 +07:00
Koakuma 5e2045cbe5 stage2: sparcv9: Implement basic asm codegen 2022-04-14 22:18:06 +07:00
Koakuma 42f4bd3421 stage2: sparcv9: Add breakpoint, ret, and calling mechanism 2022-04-14 22:18:06 +07:00
Koakuma 1972a2b080 stage2: sparcv9: Add placeholders to generate a minimal program 2022-04-14 22:18:06 +07:00
Koakuma cec48f2cf1 stage2: sparcv9: Different formatting for genBody 2022-04-14 22:18:06 +07:00
Koakuma 5ab6b5a777 stage2: sparcv9: implement dbgAdvancePCAndLine 2022-04-14 22:18:06 +07:00
Koakuma 71cd3466ec stage2: sparcv9: Adjust RegisterManager settings 2022-04-14 22:18:06 +07:00
Koakuma 18c98eb429 stage2: sparcv9: Placeholder for Air instructions in genBody 2022-04-14 22:18:06 +07:00
Koakuma 94d70bdb69 stage2: sparcv9: Change ordering in Mir Tag 2022-04-14 22:18:05 +07:00
Koakuma 94a84e783e stage2: sparcv9: Implement basic prologue/epilogue Mir emission 2022-04-14 22:18:05 +07:00
Koakuma 927706e6d0 stage2: sparcv9: Emit debug inst placeholder 2022-04-14 22:18:05 +07:00
Koakuma cf13356dab stage2: sparcv9: Mir extraData implementation 2022-04-14 22:18:05 +07:00
Koakuma 1ba5227216 stage2: sparcv9: Initial resolveCallingConventionValues implementation 2022-04-14 22:18:05 +07:00
Koakuma a5a89fde13 stage2: sparcv9: Add skeleton codegen impl and necessary fields 2022-04-14 22:18:05 +07:00
Koakuma a30688ef2a stage2: sparcv9: Add some initial checks in codegen 2022-04-14 22:18:05 +07:00
Andrew Kelley 2a00df9c09 Sema: fix generic instantiation false negatives
The problem was that types of non-anytype parameters were being included
as part of the check to see if generic function instantiations were
equal. Now, Module.Fn additionally stores the information for whether each
parameter is anytype or not. `generic_poison` cannot be used to signal
this because the type is still needed for comptime arguments; in such
case the type will not be present in the newly generated function
prototype.

This presented one additional challenge: we need to compare equality of
two values where one of them is post-coercion and the other is not. So
we make some minor adjustments to `Type.eql` to support this. I think
this small complexity tradeoff is worth it because it means the compiler
does much less work on the hot path that a generic function is called
and there is already an existing matching instantiation.

closes #11146
2022-04-14 06:08:28 -07:00
Jakub Konka edb428fae4 macho,x64: resolve debug info relocs for RIP-based addressing
Sometimes we will want to generate debug info for a constant that
has been lowered to memory and not copied anywhere else. For this
we will need to defer resolution on PIE platforms until all locals
(including GOT entries) have been allocated.
2022-04-13 19:50:23 +02:00
Jakub Konka 3f912430bd stage2,x64: deref memory if referenced via GOT for local vars 2022-04-13 16:24:56 +02:00
Jakub Konka 0bf7283330 dwarf: gen debug info for arrays 2022-04-13 16:22:24 +02:00
Jakub Konka 4c50a27d68 stage2,x64: generate debug info for local vars at hardcoded mem addr 2022-04-13 14:31:04 +02:00
Jakub Konka baeff1762b stage2,x64: recursively mark decls as alive when lowering 2022-04-13 13:52:01 +02:00
Cody Tapscott aaac8eae68 Use 0-indexing for incremental compile error tests 2022-04-13 01:09:21 -04:00
Andrew Kelley 7972bc8aa8 Sema: fix struct init ref 2022-04-12 12:20:08 -07:00
Andrew Kelley ff7ef624f5 Sema: fix comptime call with generic function as parameter 2022-04-12 12:19:32 -07:00
Andrew Kelley 99657dca1f Sema: fix comptime equality of extern unions with same tag 2022-04-12 11:36:26 -07:00
Andrew Kelley b0edd8752a Liveness: modify encoding to support over 32 operands
Prior to this, Liveness encoded `asm`, `call`, and `aggregate_init` with
a single 32-bit integer, allowing up to 35 operands (3 are provided by
the regular tomb_bits). However, the Zig language allows function calls
with more than 35 arguments, inline assembly with more than 35 inputs,
and anonymous tuples with more than 35 elements.

The new encoding stores an index to the extra array instead of the bits
directly, and then as many extra elements as needed to encode all the
operands. The MSB is used as a flag to tell which element is the last
one, allowing for 31 bits per element.

Prior to this, print_air did not bother correctly printing tombstones
for these instructions; now it does.

In addition to updating the BigTomb iteration logic in the machine code
backends, this commit extracts the common logic into the Liveness namespace.
2022-04-12 11:22:12 -07:00
Andrew Kelley bb4e74103b Merge pull request #11417 from topolarity/incremental-tests
Add file support for incremental compile error tests
2022-04-12 06:27:09 -04:00
jagt b9d86c6bc8 fix link.renameTmpIntoCache on windows when dest dir exists.
Previously it would fail as `renameW` do not ever fail with
`PathAlreadyExists`.

As a workaround we check for dest dir existence before rename
on Windows.
2022-04-12 06:01:25 -04:00
Cody Tapscott 879b562779 Add file support for incremental error tests
Compile error test cases can now be given as a sequence of files:
  - "foo.1.zig"
  - "foo.2.zig"
  - "foo.3.zig"
  - etc.

This sequence of files is tested as incremental compilation updates to a
single "foo.zig" source file.

To help avoid mistakes, we enforce strict ordering for these files.
"foo.zig" cannot co-exist with "foo.X.zig", the sequence must include
"foo.1.zig", and no numbers may be skipped.
2022-04-11 15:35:28 -07:00
Cody Tapscott 7851377e95 Improve whitespace-handling in (compile-error) test manifest parsing 2022-04-11 10:05:00 -07:00
Andrew Kelley 6ae8fe193b Liveness: utilize Air.refToIndex 2022-04-07 23:19:19 -07:00
Andrew Kelley 737ef3e81b Sema: remove unnecessary type resolution
This causes false positive "foo depends on itself" errors. Prior to some
recent enhancements, this type resolution was needed, however, we now
have a more sophisticated type resolution mechanism that fully
resolves types for the backend, but only after the Decl is fully
analyzed, avoiding dependency loops.
2022-04-07 22:58:50 -07:00
Andrew Kelley 289ba5dfc2 stage2: rename InternArena to InternPool 2022-04-06 11:50:23 -07:00
Andrew Kelley 62f54aa39c Sema: in-memory coercion of differently named int types
which have the same number of bits and the same signedness.
2022-04-06 02:39:55 -07:00
Andrew Kelley 9213aa789b stage2: ThreadPool: update to new function pointer semantics 2022-04-05 23:16:35 -07:00
Andrew Kelley dd9782a8bc Sema: fix handling compile errors during circular dependency error
Previously, Zig would try to generate a function whose type contained
structs or unions which had not been fully resolved due to circular
dependency errors. With this commit, `resolveTypeFully` will be sure to
return `error.AnalysisFail` even in this scenario, leading to proper
display of compilation errors instead of a crash.
2022-04-05 23:16:35 -07:00
Luuk de Gram ac873367b9 wasm: Use 'select' instruction for max/min
Rather than using blocks and control flow to check which operand is the maximum or minimum,
we use wasm's `select` instruction which returns us the operand based on a result from a comparison.
This saves us the need of control flow, as well as reduce the instruction count from 13 to 7.
2022-04-05 21:56:25 +02:00
Damien Firmenich 5fafcc2b62 zig fmt: remove trailing whitespace on doc comments
Fixes #11353

The renderer treats comments and doc comments differently since doc
comments are parsed into the Ast. This commit adds a check after getting
the text for the doc comment and trims whitespace at the end before
rendering.

The `a = 0,` in the test is here to avoid a ParseError while parsing the
test.
2022-04-05 18:08:33 +03:00
Andrew Kelley 95a87e88fa Sema: forward switch condition to captures 2022-04-04 22:46:05 -07:00
Andrew Kelley 51ef31a833 Sema: add empty tuple to mutable slice coercion 2022-04-04 14:29:08 -07:00
Jakub Konka 364e53f3bf dwarf: emit debug info for local variables on x86_64
Add support for emitting debug info for local variables within a subprogram.
This required moving bits responsible for populating the debug info back to
`CodeGen` from `Emit` as we require the operand to be resolved at callsite
plus we need to know its type. Without enforcing this, we could end up
with a `dead` mcv.
2022-04-04 21:46:53 +02:00
Tom Read Cutting cdcb34cdf4 Pull elf magic string out to re-used constant 2022-04-04 15:33:24 +03:00