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

Tests passing and returning small aggregate types (structs) by value. More...

#include "common/double_tap.h"
#include "types.h"
#include <common/infix_config.h>
#include <infix/infix.h>
#include <math.h>
Include dependency graph for 101_by_value.c:

Macros

#define DBLTAP_IMPLEMENTATION
 

Functions

double process_point_by_value (Point p)
 Can be defined by the user to disable all intrinsic-related code.
 
Point return_point_by_value (void)
 Returns a Point struct by value.
 
int process_mixed_struct (MixedIntDouble s)
 Processes a mixed-type struct, checking its members. (SysV x64 only)
 
float sum_vector4 (Vector4 vec)
 Sums the elements of a Vector4 HFA. (AArch64 only)
 
 subtest ("Simple struct (Point) passed and returned by value")
 
 subtest ("ABI Specific: System V x64 mixed-register struct")
 
 subtest ("ABI Specific: AArch64 Homogeneous Floating-point Aggregate (HFA)")
 
 subtest ("ABI Specific: 128-bit SIMD Vector")
 
 subtest ("ABI Specific: 256-bit AVX Vector")
 
 subtest ("ABI Specific: ARM64 Scalable Vector (SVE)")
 

Variables

 TEST
 

Detailed Description

Tests passing and returning small aggregate types (structs) by value.

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

This suite verifies the library's ability to handle one of the most complex aspects of any ABI: the rules for passing and returning structs in CPU registers. The behavior is highly platform-dependent.

This file consolidates several previous tests into a single, cohesive suite with the following goals:

  1. General Case: Tests a simple struct { double; double; } to verify basic aggregate handling on all platforms.
  2. System V x64 Specific: Tests a struct { int; double; }, which the SysV ABI dictates should be split and passed in one GPR and one XMM register.
  3. AArch64 (ARM64) Specific: Tests a struct { float v[4]; }, which is a Homogeneous Floating-point Aggregate (HFA) and should be passed in four consecutive floating-point registers.
  4. SIMD Vector Types: Contains conditionally compiled tests for native SIMD vector types, including 128-bit SSE (__m128d), 256-bit AVX (__m256d), AArch64 NEON (float64x2_t), and AArch64 SVE (svfloat64_t).

Platform-specific tests are conditionally compiled using preprocessor guards to ensure they only run on relevant targets.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

Function Documentation

◆ process_mixed_struct()

int process_mixed_struct ( MixedIntDouble  s)

Processes a mixed-type struct, checking its members. (SysV x64 only)

◆ process_point_by_value()

double process_point_by_value ( Point  p)

Can be defined by the user to disable all intrinsic-related code.

Processes a Point struct passed by value, returning a sum of its members.

◆ return_point_by_value()

Point return_point_by_value ( void  )

Returns a Point struct by value.

◆ subtest() [1/6]

subtest ( "ABI Specific: 128-bit SIMD Vector"  )

◆ subtest() [2/6]

subtest ( "ABI Specific: 256-bit AVX Vector"  )

◆ subtest() [3/6]

subtest ( "ABI Specific: AArch64 Homogeneous Floating-point Aggregate (HFA)"  )

◆ subtest() [4/6]

subtest ( "ABI Specific: ARM64 Scalable Vector (SVE)"  )

◆ subtest() [5/6]

subtest ( "ABI Specific: System V x64 mixed-register struct"  )

◆ subtest() [6/6]

subtest ( "Simple struct (Point) passed and returned by value"  )

◆ sum_vector4()

float sum_vector4 ( Vector4  vec)

Sums the elements of a Vector4 HFA. (AArch64 only)

Variable Documentation

◆ TEST

TEST
Initial value:
{
plan(6)
#define plan(count)
Definition double_tap.h:132