Skip to content

ABI #173

@tahadostifam

Description

@tahadostifam
  • Endianness support for integers.
  • Custom alignment feature.
  • Bits (Packed Structs)
  • Stack Layout
  • Target Triple & Data Layout
  • Linkage & Visibility
    • Symbol Visibility Attributes: (e.g., default, hidden, protected for ELF). These affect how the linker processes symbols and if they can be overridden.
  • C ABI Compatibility
  • Exception Handling
    • DWARF unwinding tables, Windows SEH, or other OS-specific mechanisms.
    • Tracing features.

✅ Calling Convention Support (Planned / In Progress)

Support for various calling conventions in the Cyrus Language compiler:

🧩 General Conventions

  • "C" — Standard C ABI (platform-specific)
  • "system" — Platform-default ABI ("C" on Unix, "stdcall" on Win32)

🪟 Windows-specific Conventions (x86 / x64)

  • "stdcall" — Windows API (callee cleans up stack)
  • "fastcall" — Pass first args in registers (ECX, EDX)
  • "vectorcall" — Optimized for SIMD-heavy code (XMM/AVX regs)
  • "thiscall" — Used for instance methods in C++ (ECX holds this)
  • "win64" — Official Windows x64 calling convention

🐧 Unix-like (Linux/macOS)

  • "sysv64" — System V x86_64 ABI

🧠 Cross-Target ABIs

  • "ms_abi" — Microsoft x64 ABI on non-Windows
  • "sysv_abi" — SysV ABI on Windows (e.g. mingw interop)

🦾 ARM / Embedded

  • "aapcs" — ARM EABI (32-bit)
  • "aapcs-vfp" — ARM EABI + floating point registers

⚙️ Special / Platform-specific

  • "ccc" — LLVM's internal C calling convention
  • "spir_function" — SPIR-V for OpenCL
  • "kernel" — GPU kernel launch ABI

  • Packed structs

If you manually pack a struct, LLVM may lower the alignment to 1 unless you override.
You might want to enforce natural alignment for a field to match a C ABI.

  • SIMD types (e.g., v4f32) often need 16-byte alignment.

  • Interfacing with external code (*)

If you’re generating globals or structs that will be accessed by C libraries, the alignment must match the ABI expected by the other code.
Example: passing a struct to printf or a library function. Misalignment can cause crashes or undefined behavior on some platforms.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions