aboutsummaryrefslogtreecommitdiff
path: root/src/codegen/c.zig
AgeCommit message (Collapse)Author
2023-02-23CBE: delete stage1 hacksJacob Young
2023-02-23CBE: fix MSVC diagnostics generated by the behavior testsJacob Young
After this, the last MSVC warnings are in behavior/bugs/529.zig: behavior.c(37971): warning C4133: 'function': incompatible types - from 'A__8479 *' to 'A__8474 *' behavior.c(37974): warning C4133: 'function': incompatible types - from 'A__8480 *' to 'A__8474 *'
2023-02-23CBE: support call attributesJacob Young
* Support always_tail and never_tail/never_inline with a comptime callee using clang * Support never_inline using gcc * Support never_inline using msvc Unfortunately, can't enable behavior tests because of the conditional support.
2023-02-23CBE: implement c varargsJacob Young
Removed some backend test skip checks for things disabled in std.
2023-02-23CBE: cleanup field accessJacob Young
* Implement @fieldParentPtr on a union * Refactor field access to ensure that it is handled consistently * Remove `renderTypecast` as it is now behaves the same as `renderType`
2023-02-22Merge pull request #14691 from jacobly0/ctypeAndrew Kelley
2023-02-21CBE: fix windows test failuresJacob Young
2023-02-21Sema: implement @fieldParentPtr for unionsIsaac Freund
2023-02-21CBE: fix test failuresJacob Young
2023-02-21CBE: use CType for type definitionsJacob Young
2023-02-21CBE: remove typedef data structuresJacob Young
Adds a new mechanism for `@tagName` function generation that doesn't piggyback on the removed typedef system.
2023-02-20CBE: use stdint.h types instead of `zig_` prefixesJacob Young
This requires manual defines before C99 which may not have stdint.h. Also have update-zig1 leave a copy of lib/zig.h in stage1/zig.h, which allows lib/zig.h to be updated without needing to update zig1.wasm. Note that since the object already existed with the exact same contents, this completely avoids repo bloat due to zig.h changes.
2023-02-20CBE: use CType for type renderingJacob Young
2023-02-20CBE: add CType interningJacob Young
2023-02-18update std lib and compiler sources to new for loop syntaxAndrew Kelley
2023-01-31move compiler's CType logic to std.TargetAndrew Kelley
This API only depends on std.Target and is extremely useful in build scripts when populating configure files.
2023-01-29cbe: fixes for tls, support for not linking libc, and enabling testskcbanner
- cbe: Implement linksection support, to support TLS when not linking libc - cbe: Support under-aligned variables / struct fields - cbe: Support packed structs (in the C definition of packed) - windows: Fix regression with x86 _tls_array - compiler_rt: Add 128-bit atomics to compiler_rt - tests: Re-enable threadlocal tests on cbe+windows, and llvm+x86 - tests: Re-enable f80 tests that now pass - ci: change windows ci to run the CBE behaviour tests with -lc, to match how the compiler is bootstrapped - update zig1.wasm
2023-01-29cbe: don't emit unused undefined array literalskcbanner
2023-01-23zig fmt fixupkcbanner
2023-01-23cbe: fixes for x86kcbanner
- Emit calling convention - Fix .Naked handling for msvc - Add teb helper for x86 - Fix 128-bit shl implementation when rhs is >= 64 - Add 128-bit shl tests
2023-01-02fmt fixupskcbanner
2023-01-01cbe: changes to get zig2.c compiling under msvckcbanner
- Add cpuid / getXCR0 functions for the cbe to use instead of asm blocks - Don't cast between 128 bit types during truncation - Fixup truncation to use functions for shifts / adds - Fixup float casts for undefined values - Add test for 128 bit integer truncation
2023-01-01cbe: fixes for compiling zig2.c under msvckcbanner
- add zig_mul_i128 - render slice structs in static initializers without casts / c99 style init - add negative numbers and u128 to 128-bit multiply test
2023-01-01cbe: all behaviour tests now pass on msvckcbanner
- Fix zig_clz_u128 not respecting the bits argument. This was crashing the compile-rt addxf3 tests with the cbe - Instead of redering a negation for negative 128 bit int literals, render the literal as twos complement. This allows rendering int representations of floats correctly (specifically f80).
2023-01-01cbe: msvc atomicskcbanner
- Implement most atomic operations for msvc - Disable "atomicrmw with floats" test for cbe
2023-01-01cbe: airNot emits zig_not_ calls for integerskcbanner
2023-01-01cbe: 32 bit fixup for update-zig1kcbanner
2023-01-01cbe: more msvc compatibility workkcbanner
- Add .StaticInitializer to ValueRenderLocation to indicate that the emitted values must be constant expressions (no function calls, struct casting). - Add new path for special float types (nan, inf) that works in constant expressions - Implement windows.teb() using a syscall for .stage2_c because x64 MSVC doesn't support any kind of inline asm
2023-01-01cbe: nan builtins on msvc, fixup C2099 errors in static initializerskcbanner
- Map the __builtin_nan(f|l)? functions to nan(f|l)? on msvc - MSVC throws C2099 when initializing a struct with cast syntax in a global initializer. Added zig_as_init_ to handle this case, and generate it only in static initializers for > 64 bit ints. - Change float initialization to emit the integer representation in global initializers to avoid C2099 caused by calling nan.
2023-01-01cbe: msvc compatible int casting inside renderValue .Packed branchkcbanner
- Handle non-abiInt source types (like packed union) as sources in renderIntCast
2023-01-01cbe: more msvc fixeskcbanner
- Add Function.renderIntcast to handle common casting cases - Fixup casting inside aggregate initialization - Remove redundant cast in aggregate initialization - Fix renderValue .Packed branch for > 64 bit types
2023-01-01cbe: msvc compatibility for > 64 bit intcasts and truncating from > 64 to < ↵kcbanner
64 bit - Uses zig_as/zig_lo as necessary when int casting to support !zig_has_int128 - Remove redundant cast if the type is the same - Use zig_lo when truncating > 64 bits
2023-01-01cbe: handle msvc struct casting quirkkcbanner
MSVC can't explicitly cast a struct to a typedef of itself (ie. f128 to i128). Added a set of macros to handle float casting, and to not produce a cast for this specific case on MSVC. A better approach would probably be to know if the cast is redundant and not do it.
2023-01-01cbe: fixup casting to/from 128 bit int types, as they may not have compiler ↵kcbanner
support
2023-01-01cbe: first set of changes for msvc compatibilitykcbanner
- Forward declare int builtins, so the definitions aren't assumed incorrectly - Add define to handle MSVC not support static const in function parameter array lengths - Fixup several spots where int128 support was assumed. - Support zig_align - Support zig_export - Stub out some missing non-builtin functions - Added StringLiteral to automatically split string literals when they get to 16380 in size, which is the maxmimum pre-concatenation string literal size on MSVC.
2022-12-24CBE: fix emitting a partially undefined string literalJacob Young
2022-12-21CBE: fix bitwise notJacob Young
Closes #13911
2022-12-18cbe: fix type passed to renderParentPtrJacob Young
2022-12-18codegen: fix taking the address of a zero-bit field in a zero-bit structJacob Young
Normally when we want a pointer to the end of a struct we just add 1 to the struct pointer. However, when it is a zero-bit struct, the pointer type being used during lowering is often a dummy pointer type that actually points to a non-zero-bit type, so we actually want to add 0 instead, since a zero-bit struct begins and ends at the same address.
2022-12-17implement defining C variadic functionsVeikka Tuominen
2022-12-15port packed vector elem ptr logic from stage1Veikka Tuominen
Closes #12812 Closes #13925
2022-12-13remove `stack` option from `@call`Veikka Tuominen
2022-12-10CBE: fix compiling for aarch64-windowsJacob Young
These bugs were triggered in the C backend by aarch64-specific code in os/windows.zig. Intentionally not updating zig1.wasm yet because of upcoming changes and since aarch64-windows is not tested on master yet.
2022-12-09Eliminate `BoundFn` type from the languageVeikka Tuominen
Closes #9484
2022-12-06remove most conditional compilation based on stage1Andrew Kelley
There are still a few occurrences of "stage1" in the standard library and self-hosted compiler source, however, these instances need a bit more careful inspection to ensure no breakage.
2022-12-06CBE: avoid trailing spaceJacob Young
2022-12-06CBE: add windows-specific reserved identifiersJacob Young
2022-12-06CBE: fix bad local reuse for volatile memsetJacob Young
2022-12-04CBE: revert broken change that got missedJacob Young
2022-12-04CBE: defer invariant local reuse in loopsJacob Young
When a local defined outside a loop dies inside the loop, it can still be needed on subsequent loop iterations, so reuse of the local must be deferred until after the loop ends. This causes behavior tests to pass.