|
infix
A JIT-Powered FFI Library for C
|
Unit test for passing and returning aggregates and vectors by value. More...
#include "common/double_tap.h"#include "common/infix_internals.h"#include "types.h"#include <infix/infix.h>#include <math.h>#include <stdbool.h>Classes | |
| struct | Char20Struct |
Macros | |
| #define | DBLTAP_IMPLEMENTATION |
Functions | |
| double | process_point_by_value (Point p) |
| Point | return_point_by_value (void) |
| int | process_mixed_struct (MixedIntDouble s) |
| float | sum_vector4 (Vector4 vec) |
| int | process_char20_struct (Char20Struct s) |
| A C function that receives the 20-byte struct. | |
| int | process_char_array_param (char s[20]) |
| A C function that receives a char array parameter. | |
| 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)") | |
| subtest ("ABI Specific: 512-bit AVX-512 Vector (__m512d)") | |
| subtest ("ABI Specific: 512-bit AVX-512 Vector (__m512)") | |
| subtest ("SysV ABI: Passing a 20-byte aggregate") | |
| subtest ("SysV ABI: Passing an array parameter (decays to pointer)") | |
Variables | |
| TEST | |
Unit test for passing and returning aggregates and vectors by value.
This test file is crucial for validating the ABI implementation for passing and returning aggregate types (structs, arrays, vectors) directly in CPU registers, where the ABI allows it. Different ABIs have complex and divergent rules for this, which this test aims to cover.
It tests several key ABI-specific scenarios:
{ double, double }) are correctly passed and returned in floating-point or general-purpose registers as per the ABI (e.g., in XMM0/XMM1 on SysV, or X0/X1 on AArch64).{ int, double } is split and passed in both a GPR (for the int) and an XMM register (for the double).__m128d on x86 or float64x2_t on ARM) are correctly passed and returned in SIMD registers. This includes checks for SSE2, AVX2, and NEON types, conditionally compiled based on architecture. | #define DBLTAP_IMPLEMENTATION |
| int process_char20_struct | ( | Char20Struct | s | ) |
A C function that receives the 20-byte struct.
It checks if the received data matches the expected pattern. A correct call will result in a return value of 1, while a call where the argument was corrupted (e.g., by being partially passed in registers) will fail the check and return 0.
| int process_char_array_param | ( | char | s[20] | ) |
A C function that receives a char array parameter.
The ABI will treat s as char*. This function verifies that the pointer is valid and the data it points to is correct.
| int process_mixed_struct | ( | MixedIntDouble | s | ) |
| double process_point_by_value | ( | Point | p | ) |
| Point return_point_by_value | ( | void | ) |
| subtest | ( | "ABI Specific: 128-bit SIMD Vector" | ) |
| subtest | ( | "ABI Specific: 256-bit AVX Vector" | ) |
| subtest | ( | "ABI Specific: 512-bit AVX-512 Vector (__m512)" | ) |
| subtest | ( | "ABI Specific: 512-bit AVX-512 Vector (__m512d)" | ) |
| subtest | ( | "ABI Specific: AArch64 Homogeneous Floating-point Aggregate (HFA)" | ) |
| subtest | ( | "ABI Specific: ARM64 Scalable Vector (SVE)" | ) |
| subtest | ( | "ABI Specific: System V x64 mixed-register struct" | ) |
| subtest | ( | "Simple struct (Point) passed and returned by value" | ) |
| subtest | ( | "SysV ABI: Passing a 20-byte aggregate" | ) |
| subtest | ( | "SysV ABI: Passing an array parameter (decays to pointer)" | ) |
| float sum_vector4 | ( | Vector4 | vec | ) |