Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace std.builtin.CallingConvention with a tagged union, eliminating @setAlignStack #21697

Merged
merged 28 commits into from
Oct 23, 2024

Commits on Oct 19, 2024

  1. compiler: introduce new CallingConvention

    This commit begins implementing accepted proposal ziglang#21209 by making
    `std.builtin.CallingConvention` a tagged union.
    
    The stage1 dance here is a little convoluted. This commit introduces the
    new type as `NewCallingConvention`, keeping the old `CallingConvention`
    around. The compiler uses `std.builtin.NewCallingConvention`
    exclusively, but when fetching the type from `std` when running the
    compiler (e.g. with `getBuiltinType`), the name `CallingConvention` is
    used. This allows a prior build of Zig to be used to build this commit.
    The next commit will update `zig1.wasm`, and then the compiler and
    standard library can be updated to completely replace
    `CallingConvention` with `NewCallingConvention`.
    
    The second half of ziglang#21209 is to remove `@setAlignStack`, which will be
    implemented in another commit after updating `zig1.wasm`.
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    51706af View commit details
    Browse the repository at this point in the history
  2. stage1: update zig1.wasm

    As well as being necessary for the `CallingConvention` changes, this
    update includes the following notable changes:
    
    * Fix unlabeled `break` targeting the wrong scope in the presence of
      labeled continue, unblocking ziglang#21422
    * Implement `@FieldType`
    * Implement `@splat` on arrays
    
    Signed-off-by: mlugg <mlugg@mlugg.co.uk>
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    36405b9 View commit details
    Browse the repository at this point in the history
  3. std: update for new CallingConvention

    The old `CallingConvention` type is replaced with the new
    `NewCallingConvention`. References to `NewCallingConvention` in the
    compiler are updated accordingly. In addition, a few parts of the
    standard library are updated to use the new type correctly.
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    bc797a9 View commit details
    Browse the repository at this point in the history
  4. compiler: remove @setAlignStack

    This commit finishes implementing ziglang#21209 by removing the
    `@setAlignStack` builtin in favour of `CallingConvention` payloads. The
    x86_64 backend is updated to use the stack alignment given in the
    calling convention (the LLVM backend was already updated in a previous
    commit).
    
    Resolves: ziglang#21209
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    ec19086 View commit details
    Browse the repository at this point in the history
  5. test: update for CallingConvention changes

    This also includes some compiler and std changes to correct error
    messages which weren't properly updated before.
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    4be0cf3 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    cbfe00b View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    2d9a167 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    6657982 View commit details
    Browse the repository at this point in the history
  9. link: add clarifying comment

    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    a2c519b View commit details
    Browse the repository at this point in the history
  10. std.builtin.CallingConvention: RISC-V PrivilegeLevel -> `PrivilegeM…

    …ode`
    
    The RISC-V specification uses these terms a little interchangably, but
    "mode" seems more correct here.
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    67580ed View commit details
    Browse the repository at this point in the history
  11. cbe,translate-c: support more callconvs

    There are several more that we could support here, but I didn't feel
    like going down the rabbit-hole of figuring them out. In particular,
    some of the Clang enum fields aren't specific enough for us, so we'll
    have to switch on the target to figure out how to translate-c them. That
    can be a future enhancement.
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    cb48376 View commit details
    Browse the repository at this point in the history
  12. Sema: minor cleanup

    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    d466c08 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    2319d62 View commit details
    Browse the repository at this point in the history
  14. compiler: avoid unreasonable eval branch quotas

    Using `@FieldType` (ziglang#21702).
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    0b78605 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    ed862b0 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    1f11eed View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    bde68fd View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    1d1e8e1 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    3ef8bb6 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    8302301 View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    04ffc1c View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    28cb887 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    289b2f8 View commit details
    Browse the repository at this point in the history
  24. compiler_rt: remove bogus tests

    These only worked before because our lowering of the `AAPCS` calling
    convention was incorrect in a way which happened to match the ABI of
    these functions. The tests aren't actually very helpful -- there are
    already tests for `divmoddi4` etc -- so rather than using inline asm on
    the caller side to match the ABI, we just delete these two tests.
    
    We were for some reason missing a direct test for `__udivmodsi4`, so one
    has been added.
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    cf39652 View commit details
    Browse the repository at this point in the history
  25. x86_64,riscv64: fix incorrect incoming_stack_alignment handling

    The whole motivation behind this proposal in the first place was that
    the LLVM backend disagrees with the self-hosted backends on what
    `@setAlignStack` meant, so we can't just translate the old logic to the
    new system! These backends can introduce support for overriding
    `incoming_stack_alignment` later on.
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    387965a View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    73f4c68 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    8d5ac6b View commit details
    Browse the repository at this point in the history
  28. riscv: disable failing test

    Looks like the self-hosted riscv64 backend can't handle `std.meta.eql`
    involving the new `CallingConvention` right now.
    mlugg committed Oct 19, 2024
    Configuration menu
    Copy the full SHA
    f7d679c View commit details
    Browse the repository at this point in the history