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

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Commits on Oct 17, 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 17, 2024
    Configuration menu
    Copy the full SHA
    4fe966d View commit details
    Browse the repository at this point in the history
  2. stage1: update zig1.wasm

    Signed-off-by: mlugg <[email protected]>
    mlugg committed Oct 17, 2024
    Configuration menu
    Copy the full SHA
    28aafa6 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 17, 2024
    Configuration menu
    Copy the full SHA
    0f66ec6 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 17, 2024
    Configuration menu
    Copy the full SHA
    b442da2 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 17, 2024
    Configuration menu
    Copy the full SHA
    99be949 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    0f5889e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    ca07f24 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    8dabad6 View commit details
    Browse the repository at this point in the history
  9. link: add clarifying comment

    mlugg committed Oct 17, 2024
    Configuration menu
    Copy the full SHA
    0baf775 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 17, 2024
    Configuration menu
    Copy the full SHA
    8339934 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 17, 2024
    Configuration menu
    Copy the full SHA
    b0b30d0 View commit details
    Browse the repository at this point in the history
  12. Sema: minor cleanup

    mlugg committed Oct 17, 2024
    Configuration menu
    Copy the full SHA
    15d3025 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    67c53d3 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    e92b416 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    8152020 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    9f644cb View commit details
    Browse the repository at this point in the history
  17. Configuration menu
    Copy the full SHA
    a73781e View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    0292fe0 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    42eafbc View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    766290a View commit details
    Browse the repository at this point in the history
  21. Configuration menu
    Copy the full SHA
    4994d47 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    e36d270 View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    b2dfb69 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.
    mlugg committed Oct 17, 2024
    Configuration menu
    Copy the full SHA
    f819f7a 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 17, 2024
    Configuration menu
    Copy the full SHA
    49ddffe View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    39dd828 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    b77fe59 View commit details
    Browse the repository at this point in the history