infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
abi_arm64.c File Reference

Implements the FFI logic for the AArch64 (ARM64) architecture. More...

#include "arch/aarch64/abi_arm64_common.h"
#include "arch/aarch64/abi_arm64_emitters.h"
#include "common/infix_internals.h"
#include "common/utility.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for abi_arm64.c:

Macros

#define NUM_GPR_ARGS   8
#define NUM_VPR_ARGS   8
#define MAX_AGGREGATE_FIELDS_TO_CLASSIFY   32

Functions

static bool is_hfa (const infix_type *type, const infix_type **base_type)
static infix_status prepare_forward_call_frame_arm64 (infix_arena_t *arena, infix_call_frame_layout **out_layout, infix_type *ret_type, infix_type **arg_types, size_t num_args, size_t num_fixed_args, void *target_fn)
static infix_status generate_forward_prologue_arm64 (code_buffer *buf, infix_call_frame_layout *layout)
static infix_status generate_forward_argument_moves_arm64 (code_buffer *buf, infix_call_frame_layout *layout, infix_type **arg_types, size_t num_args, c23_maybe_unused size_t num_fixed_args)
static infix_status generate_forward_call_instruction_arm64 (code_buffer *, infix_call_frame_layout *)
static infix_status generate_forward_epilogue_arm64 (code_buffer *buf, infix_call_frame_layout *layout, infix_type *ret_type)
static infix_status prepare_reverse_call_frame_arm64 (infix_arena_t *arena, infix_reverse_call_frame_layout **out_layout, infix_reverse_t *context)
static infix_status generate_reverse_prologue_arm64 (code_buffer *buf, infix_reverse_call_frame_layout *layout)
static infix_status generate_reverse_argument_marshalling_arm64 (code_buffer *buf, infix_reverse_call_frame_layout *layout, infix_reverse_t *context)
static infix_status generate_reverse_dispatcher_call_arm64 (code_buffer *buf, infix_reverse_call_frame_layout *layout, infix_reverse_t *context)
static infix_status generate_reverse_epilogue_arm64 (code_buffer *buf, infix_reverse_call_frame_layout *layout, infix_reverse_t *context)
static infix_status prepare_direct_forward_call_frame_arm64 (infix_arena_t *arena, infix_direct_call_frame_layout **out_layout, infix_type *ret_type, infix_type **arg_types, size_t num_args, infix_direct_arg_handler_t *handlers, void *target_fn)
static infix_status generate_direct_forward_prologue_arm64 (code_buffer *buf, infix_direct_call_frame_layout *layout)
static infix_status generate_direct_forward_argument_moves_arm64 (code_buffer *buf, infix_direct_call_frame_layout *layout)
static infix_status generate_direct_forward_call_instruction_arm64 (code_buffer *buf, infix_direct_call_frame_layout *layout)
static infix_status generate_direct_forward_epilogue_arm64 (code_buffer *buf, infix_direct_call_frame_layout *layout, infix_type *ret_type)
static const infix_type * get_hfa_base_type (const infix_type *type)
static bool is_hfa_recursive_check (const infix_type *type, const infix_type *base_type, size_t *field_count)
static infix_status generate_forward_call_instruction_arm64 (code_buffer *buf, c23_maybe_unused infix_call_frame_layout *layout)

Variables

static const arm64_gpr GPR_ARGS [] = {X0_REG, X1_REG, X2_REG, X3_REG, X4_REG, X5_REG, X6_REG, X7_REG}
static const arm64_vpr VPR_ARGS [] = {V0_REG, V1_REG, V2_REG, V3_REG, V4_REG, V5_REG, V6_REG, V7_REG}
const infix_forward_abi_spec g_arm64_forward_spec
const infix_reverse_abi_spec g_arm64_reverse_spec
const infix_direct_forward_abi_spec g_arm64_direct_forward_spec

Detailed Description

Implements the FFI logic for the AArch64 (ARM64) architecture.

Copyright (c) 2025 Sanko Robinson

This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.

SPDX-License-Identifier: (Artistic-2.0 OR MIT)

The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).

SPDX-License-Identifier: CC-BY-4.0

Macro Definition Documentation

◆ MAX_AGGREGATE_FIELDS_TO_CLASSIFY

#define MAX_AGGREGATE_FIELDS_TO_CLASSIFY   32

◆ NUM_GPR_ARGS

#define NUM_GPR_ARGS   8

◆ NUM_VPR_ARGS

#define NUM_VPR_ARGS   8

Function Documentation

◆ generate_direct_forward_argument_moves_arm64()

infix_status generate_direct_forward_argument_moves_arm64 ( code_buffer * buf,
infix_direct_call_frame_layout * layout )
static

◆ generate_direct_forward_call_instruction_arm64()

infix_status generate_direct_forward_call_instruction_arm64 ( code_buffer * buf,
infix_direct_call_frame_layout * layout )
static

◆ generate_direct_forward_epilogue_arm64()

infix_status generate_direct_forward_epilogue_arm64 ( code_buffer * buf,
infix_direct_call_frame_layout * layout,
infix_type * ret_type )
static

◆ generate_direct_forward_prologue_arm64()

infix_status generate_direct_forward_prologue_arm64 ( code_buffer * buf,
infix_direct_call_frame_layout * layout )
static

◆ generate_forward_argument_moves_arm64()

infix_status generate_forward_argument_moves_arm64 ( code_buffer * buf,
infix_call_frame_layout * layout,
infix_type ** arg_types,
size_t num_args,
c23_maybe_unused size_t num_fixed_args )
static

◆ generate_forward_call_instruction_arm64() [1/2]

infix_status generate_forward_call_instruction_arm64 ( code_buffer * ,
infix_call_frame_layout *  )
static

◆ generate_forward_call_instruction_arm64() [2/2]

infix_status generate_forward_call_instruction_arm64 ( code_buffer * buf,
c23_maybe_unused infix_call_frame_layout * layout )
static

◆ generate_forward_epilogue_arm64()

infix_status generate_forward_epilogue_arm64 ( code_buffer * buf,
infix_call_frame_layout * layout,
infix_type * ret_type )
static

◆ generate_forward_prologue_arm64()

infix_status generate_forward_prologue_arm64 ( code_buffer * buf,
infix_call_frame_layout * layout )
static

◆ generate_reverse_argument_marshalling_arm64()

infix_status generate_reverse_argument_marshalling_arm64 ( code_buffer * buf,
infix_reverse_call_frame_layout * layout,
infix_reverse_t * context )
static

◆ generate_reverse_dispatcher_call_arm64()

infix_status generate_reverse_dispatcher_call_arm64 ( code_buffer * buf,
infix_reverse_call_frame_layout * layout,
infix_reverse_t * context )
static

◆ generate_reverse_epilogue_arm64()

infix_status generate_reverse_epilogue_arm64 ( code_buffer * buf,
infix_reverse_call_frame_layout * layout,
infix_reverse_t * context )
static

◆ generate_reverse_prologue_arm64()

infix_status generate_reverse_prologue_arm64 ( code_buffer * buf,
infix_reverse_call_frame_layout * layout )
static

◆ get_hfa_base_type()

const infix_type * get_hfa_base_type ( const infix_type * type)
static

◆ is_hfa()

bool is_hfa ( const infix_type * type,
const infix_type ** base_type )
static

◆ is_hfa_recursive_check()

bool is_hfa_recursive_check ( const infix_type * type,
const infix_type * base_type,
size_t * field_count )
static

◆ prepare_direct_forward_call_frame_arm64()

infix_status prepare_direct_forward_call_frame_arm64 ( infix_arena_t * arena,
infix_direct_call_frame_layout ** out_layout,
infix_type * ret_type,
infix_type ** arg_types,
size_t num_args,
infix_direct_arg_handler_t * handlers,
void * target_fn )
static

◆ prepare_forward_call_frame_arm64()

infix_status prepare_forward_call_frame_arm64 ( infix_arena_t * arena,
infix_call_frame_layout ** out_layout,
infix_type * ret_type,
infix_type ** arg_types,
size_t num_args,
size_t num_fixed_args,
void * target_fn )
static

◆ prepare_reverse_call_frame_arm64()

infix_status prepare_reverse_call_frame_arm64 ( infix_arena_t * arena,
infix_reverse_call_frame_layout ** out_layout,
infix_reverse_t * context )
static

Variable Documentation

◆ g_arm64_direct_forward_spec

const infix_direct_forward_abi_spec g_arm64_direct_forward_spec
Initial value:
= {
.prepare_direct_forward_call_frame = prepare_direct_forward_call_frame_arm64,
.generate_direct_forward_prologue = generate_direct_forward_prologue_arm64,
.generate_direct_forward_argument_moves = generate_direct_forward_argument_moves_arm64,
.generate_direct_forward_call_instruction = generate_direct_forward_call_instruction_arm64,
.generate_direct_forward_epilogue = generate_direct_forward_epilogue_arm64}
static infix_status prepare_direct_forward_call_frame_arm64(infix_arena_t *arena, infix_direct_call_frame_layout **out_layout, infix_type *ret_type, infix_type **arg_types, size_t num_args, infix_direct_arg_handler_t *handlers, void *target_fn)
Definition abi_arm64.c:1253
static infix_status generate_direct_forward_argument_moves_arm64(code_buffer *buf, infix_direct_call_frame_layout *layout)
Definition abi_arm64.c:1346
static infix_status generate_direct_forward_call_instruction_arm64(code_buffer *buf, infix_direct_call_frame_layout *layout)
Definition abi_arm64.c:1578
static infix_status generate_direct_forward_prologue_arm64(code_buffer *buf, infix_direct_call_frame_layout *layout)
Definition abi_arm64.c:1322
static infix_status generate_direct_forward_epilogue_arm64(code_buffer *buf, infix_direct_call_frame_layout *layout, infix_type *ret_type)
Definition abi_arm64.c:1591

◆ g_arm64_forward_spec

const infix_forward_abi_spec g_arm64_forward_spec
Initial value:
= {
.prepare_forward_call_frame = prepare_forward_call_frame_arm64,
.generate_forward_prologue = generate_forward_prologue_arm64,
.generate_forward_argument_moves = generate_forward_argument_moves_arm64,
.generate_forward_call_instruction = generate_forward_call_instruction_arm64,
.generate_forward_epilogue = generate_forward_epilogue_arm64}
static infix_status generate_forward_argument_moves_arm64(code_buffer *buf, infix_call_frame_layout *layout, infix_type **arg_types, size_t num_args, c23_maybe_unused size_t num_fixed_args)
Definition abi_arm64.c:484
static infix_status generate_forward_call_instruction_arm64(code_buffer *, infix_call_frame_layout *)
static infix_status generate_forward_prologue_arm64(code_buffer *buf, infix_call_frame_layout *layout)
Definition abi_arm64.c:443
static infix_status prepare_forward_call_frame_arm64(infix_arena_t *arena, infix_call_frame_layout **out_layout, infix_type *ret_type, infix_type **arg_types, size_t num_args, size_t num_fixed_args, void *target_fn)
Definition abi_arm64.c:261
static infix_status generate_forward_epilogue_arm64(code_buffer *buf, infix_call_frame_layout *layout, infix_type *ret_type)
Definition abi_arm64.c:681

◆ g_arm64_reverse_spec

const infix_reverse_abi_spec g_arm64_reverse_spec
Initial value:
= {
.prepare_reverse_call_frame = prepare_reverse_call_frame_arm64,
.generate_reverse_prologue = generate_reverse_prologue_arm64,
.generate_reverse_argument_marshalling = generate_reverse_argument_marshalling_arm64,
.generate_reverse_dispatcher_call = generate_reverse_dispatcher_call_arm64,
.generate_reverse_epilogue = generate_reverse_epilogue_arm64}
static infix_status generate_reverse_argument_marshalling_arm64(code_buffer *buf, infix_reverse_call_frame_layout *layout, infix_reverse_t *context)
Definition abi_arm64.c:894
static infix_status generate_reverse_dispatcher_call_arm64(code_buffer *buf, infix_reverse_call_frame_layout *layout, infix_reverse_t *context)
Definition abi_arm64.c:1162
static infix_status generate_reverse_prologue_arm64(code_buffer *buf, infix_reverse_call_frame_layout *layout)
Definition abi_arm64.c:870
static infix_status prepare_reverse_call_frame_arm64(infix_arena_t *arena, infix_reverse_call_frame_layout **out_layout, infix_reverse_t *context)
Definition abi_arm64.c:812
static infix_status generate_reverse_epilogue_arm64(code_buffer *buf, infix_reverse_call_frame_layout *layout, infix_reverse_t *context)
Definition abi_arm64.c:1197

◆ GPR_ARGS

const arm64_gpr GPR_ARGS[] = {X0_REG, X1_REG, X2_REG, X3_REG, X4_REG, X5_REG, X6_REG, X7_REG}
static

◆ VPR_ARGS

const arm64_vpr VPR_ARGS[] = {V0_REG, V1_REG, V2_REG, V3_REG, V4_REG, V5_REG, V6_REG, V7_REG}
static