TheDan64 / inkwell

It's a New Kind of Wrapper for Exposing LLVM (Safely)
https://thedan64.github.io/inkwell/
Apache License 2.0
2.38k stars 229 forks source link

List of known calling conventions #413

Open willtunnels opened 1 year ago

willtunnels commented 1 year ago

EDIT: recalibrated my thoughts on the two possible approaches.

It would be nice to have a list of the known calling conventions in Inkwell. This list can be found in the LLVM C API here. Currently FunctionValue::get_call_conventions, FunctionValue::set_call_conventions, etc. just take a u32 and there in no hint anywhere in Inkwell what values LLVM expects.

There are two ways I see to add these constants.

  1. As variants of an enum.
  2. As constants in a module.

Based on the way to LLVM API is set up, it seems like there might be uses for unknown/unenumerated calling conventions (see, for instance, FirstTargetCC here). Perhaps, someone more familiar with the matter can weight in here. So, if we do (1) we probably need an Unknown variant which can hold an arbitrary integer.

The list of constants is:

  pub type ID = u32;
  pub const C: ID = 0;
  pub const Fast: ID = 8;
  pub const Cold: ID = 9;
  pub const GHC: ID = 10;
  pub const HiPE: ID = 11;
  pub const WebKit_JS: ID = 12;
  pub const AnyReg: ID = 13;
  pub const PreserveMost: ID = 14;
  pub const PreserveAll: ID = 15;
  pub const Swift: ID = 16;
  pub const CXX_FAST_TLS: ID = 17;
  pub const Tail: ID = 18;
  pub const CFGuard_Check: ID = 19;
  pub const SwiftTail: ID = 20;
  pub const FirstTargetCC: ID = 64;
  pub const X86_StdCall: ID = 64;
  pub const X86_FastCall: ID = 65;
  pub const ARM_APCS: ID = 66;
  pub const ARM_AAPCS: ID = 67;
  pub const ARM_AAPCS_VFP: ID = 68;
  pub const MSP430_INTR: ID = 69;
  pub const X86_ThisCall: ID = 70;
  pub const PTX_Kernel: ID = 71;
  pub const PTX_Device: ID = 72;
  pub const SPIR_FUNC: ID = 75;
  pub const SPIR_KERNEL: ID = 76;
  pub const Intel_OCL_BI: ID = 77;
  pub const X86_64_SysV: ID = 78;
  pub const Win64: ID = 79;
  pub const X86_VectorCall: ID = 80;
  pub const DUMMY_HHVM: ID = 81;
  pub const DUMMY_HHVM_C: ID = 82;
  pub const X86_INTR: ID = 83;
  pub const AVR_INTR: ID = 84;
  pub const AVR_SIGNAL: ID = 85;
  pub const AVR_BUILTIN: ID = 86;
  pub const AMDGPU_VS: ID = 87;
  pub const AMDGPU_GS: ID = 88;
  pub const AMDGPU_PS: ID = 89;
  pub const AMDGPU_CS: ID = 90;
  pub const AMDGPU_KERNEL: ID = 91;
  pub const X86_RegCall: ID = 92;
  pub const AMDGPU_HS: ID = 93;
  pub const MSP430_BUILTIN: ID = 94;
  pub const AMDGPU_LS: ID = 95;
  pub const AMDGPU_ES: ID = 96;
  pub const AArch64_VectorCall: ID = 97;
  pub const AArch64_SVE_VectorCall: ID = 98;
  pub const WASM_EmscriptenInvoke: ID = 99;
  pub const AMDGPU_Gfx: ID = 100;
  pub const M68k_INTR: ID = 101;
  pub const AArch64_SME_ABI_Support_Routines_PreserveMost_From_X0: ID = 102;
  pub const AArch64_SME_ABI_Support_Routines_PreserveMost_From_X2: ID = 103;
  pub const MaxID: ID = 1023;