aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
AgeCommit message (Collapse)Author
2022-09-09Merge remote-tracking branch 'origin/master' into llvm15Andrew Kelley
2022-09-08stage2: fix building for 32-bit targetsAndrew Kelley
2022-09-08llvm: handle pointers in packed structs in more placesVeikka Tuominen
Closes #12776
2022-09-06Merge remote-tracking branch 'origin/master' into llvm15Andrew Kelley
2022-09-04stage2 llvm: implement aarch64 C ABIVeikka Tuominen
... at least enough to pass all the current tests.
2022-09-04llvm: fix the `type` parameter of `GlobalAlias`riChar
Closes 12680
2022-09-03stage2 llvm: improve handling of i128 on Windows C ABIVeikka Tuominen
2022-09-03Sema: only ABI sized packed structs are extern compatibleVeikka Tuominen
2022-09-02stage2 llvm: correct handling of zero-bit types in unionFieldPtrVeikka Tuominen
Pointers to zero-bit types are not zero-bit types so the function should return something. Closes #12716
2022-09-02stage2 llvm: fix passing packed structs to callconv(.C) functionsVeikka Tuominen
Closes #12704
2022-08-30LLVM: fix extern functions missing attributesAndrew Kelley
Extern functions were missing attributes such as "readonly" on non-optional pointers, and "byval" which is required to match C ABI. Follow-up from bf28765a975355c27558eaa86cf00ccb29b663a7. closes #12683
2022-08-30Merge remote-tracking branch 'origin/master' into llvm15Andrew Kelley
2022-08-30avoid exposing supportsTailCall in the standard libraryAndrew Kelley
This is problematic because in practice it depends on whether the compiler backend supports it too, as evidenced by the TODO comment about LLVM not supporting some architectures that in fact do support tail calls. Instead this logic is organized strategically in src/target.zig, part of the internal compiler source code, and the behavior tests in question duplicate some logic for deciding whether to proceed with the test. The proper place to expose this flag is in `@import("builtin")` - the generated source file - so that third party compilers can advertise whether they support tail calls.
2022-08-30stage2 llvm: use tag value instead of field index in airUnionInitVeikka Tuominen
Closes #12656
2022-08-30Sema: improve handling of always_tail call modifierVeikka Tuominen
Closes #4301 Closes #5692 Closes #6281 Closes #10786 Closes #11149 Closes #11776
2022-08-29LLVM: upgrade byval attr code to LLVM 15 opaque pointersAndrew Kelley
Follow-up from 74673b7f69b27dc39a653f92eb58bba71e289f39.
2022-08-29LLVM: update merged master branch code to opaque pointersAndrew Kelley
2022-08-29Merge remote-tracking branch 'origin/master' into llvm15Andrew Kelley
2022-08-25LLVM: fix missing alignment on wrapping instructionsAndrew Kelley
Previously, when lowering AIR instructions `wrap_errunion_payload`, `wrap_errunion_err`, and `wrap_optional`, the LLVM backend would create an alloca instruction to store the result, but did not set the alignment on it. This caused UB which went undetected for a long time until we started enabling the stack protector. Closes #12594 Unblocks #12508 Inspires #12634 Tests passed locally: * test-behavior * test-cases
2022-08-24stage2: explicitly tagged enums no longer have one possible valueAndrew Kelley
Previously, Zig had inconsistent semantics for an enum like this: `enum(u8){zero = 0}` Although in theory this can only hold one possible value, the tag `zero`, Zig no longer will treat the type this way. It will do loads and stores, as if the type has runtime bits. Closes #12619 Tests passed locally: * test-behavior * test-cases
2022-08-22llvm: add valgrind client request integration for x86_64Andrew Kelley
closes #12500
2022-08-22Sema: allow optional pointers in packed structsVeikka Tuominen
Closes #12572
2022-08-21Sema: handle union and enum field order being differentVeikka Tuominen
Closes #12543
2022-08-19LLVM: add DLL export attributeAndrew Kelley
This was present in stage1 but missing from self-hosted.
2022-08-19stage2: implement stack protectorsAndrew Kelley
This is one of the final remaining TODOs for the LLVM backend.
2022-08-18std.Target gains ObjectFormat fieldAndrew Kelley
2022-08-18LLVM: disable the ABI size safety checkAndrew Kelley
There still more instances of this check being tripped during behavior tests that we need to fix before we can enable this.
2022-08-18stage2: agree with LLVM that `@alignOf(u128)` is 8Andrew Kelley
on x86_64 and similar targets.
2022-08-12stage2: check for zero in `@intToError` safetyVeikka Tuominen
2022-08-12stage2: generate a switch for `@errSetCast` safetyVeikka Tuominen
2022-08-10stage2 llvm: implement more C ABIVeikka Tuominen
2022-08-10LLVM: respect linksection for exported variablesAndrew Kelley
2022-08-10stage2: Implement explicit backing integers for packed structsIsaac Freund
Now the backing integer of a packed struct type may be explicitly specified with e.g. `packed struct(u32) { ... }`.
2022-08-05stage2 cbe: correct `airIsNull` ptr operand checkVeikka Tuominen
2022-08-05stage2: add runtime safety for invalid enum valuesVeikka Tuominen
2022-08-04stage2 LLVM backend: opaque pointer fixesAndrew Kelley
2022-08-03LLVM backends: more LLVM 15 fixesAndrew Kelley
uwtable now needs a "sync" or "async" parameter. more opaque pointer fixes
2022-08-02LLVM backend fixesAndrew Kelley
Fixing assertions hit after upgrading to opaque pointers API.
2022-08-01LLVM backends: work around poorly designed C APIAndrew Kelley
As part of the Opaque Pointers upgrade documentation, LLVM says that the function LLVMGetGEPSourceElementType() can be used to obtain element type information in lieu of LLVMGetElementType(), however, this function actually returns the struct type, not the field type. The GEP instruction does store the information we need, however, this is not exposed in the C API. It seems like they accidentally exposed the wrong field, because one would never need the struct type since one must already pass it directly to the GEP instruction, so one will always have it handy, whereas one will usually not have the field type handy.
2022-08-01fix bugs from previous two commitsAndrew Kelley
2022-08-01stage2: LLVM lowering to opaque pointers APIAndrew Kelley
2022-08-01stage1: LLVM lowering to opaque pointers APIAndrew Kelley
2022-08-01Removed param_names from Fn inside Module.zigantlilja
Removed the copy of param_names inside of Fn and changed to implementation of getParamName to fetch to parameter name from the ZIR. The signature of getParamName was also changed to take an additional *Module argument.
2022-07-31update Target, CPU, OS, ABI, etc. to LLVM 15Andrew Kelley
2022-07-31stage2 LLVM: Pass inline assembly outputs directly when not targeting memoryCody Tapscott
This change provides a basic implementation of #2349 for stage2. There's still quite a lot of work before this logic is as complete as what's in Clang (https://github.com/llvm/llvm-project/blob/b3645353041818f61e2580635409ddb81ff5a272/clang/lib/CodeGen/CGStmt.cpp#L2304-L2795), particularly considering the diversity of constraints across targets. It's probably not worth doing the complete work until there's a clearer picture for constraints in Zig's future dedicated ASM syntax, but at least this gives us a small improvement for now. As a bonus, this also fixes a bug with how we were handling `_` identifiers.
2022-07-27LLVM: fix returning extern union with C callconvAndrew Kelley
2022-07-27LLVM: fix lowering byte-aligned packed struct field pointersAndrew Kelley
2022-07-26LLVM: add probe-stack function attributeAndrew Kelley
2022-07-25wasm: Only allow lowering C-ABI compatible typesLuuk de Gram
2022-07-25llvm: correctly lower c-abi for Wasm targetLuuk de Gram
When lowering the return type for Wasm if the calling convention is `C`, it now correctly lower it according to what clang does as specified in: https://github.com/WebAssembly/tool-conventions/blob/main/BasicCABI.md This makes use of the same logic as the Wasm backend, ensuring the generated code does not diverge in function signatures. When passing arguments accross the C-ABI for the Wasm target, we want slightly different behavior than x86_64. For instance: a struct with multiple fields must always be passed by reference, even if its ABI size fits in a single integer. However, we do pass larger integers such as 128bit by value, which LLVM will correctly lower to use double arguments instead.