ffi 0.4: focused FP-aggregate (HFA) baseline — FQuad + DQuad
91/91 regression tests pass (+ffi-04-fp-struct). Single-file regression net for the all-float / all-double aggregate ABI path: FQuad — 16 B, 4×f32 (same slot as ffi-02's Vec4f) DQuad — 32 B, 4×f64 (UIEdgeInsets-shape — the f32-vs-f64 landmine) Already nominally covered by ffi-02's Vec4f, but pinning it as a focused single-file test means a future ABI rule change that breaks the HFA path fails *this* test directly without a noisy drag-in from the multi-shape baseline. DQuad at 32 B straddles the AAPCS64 HFA limit (≤4 floats of same type, total ≤64 B); it stays as a struct value passed through v0..v3 rather than going indirect. The snapshot confirms the values arrive intact.
This commit is contained in:
29
vendors/ffi_fp_struct/ffi_fp_struct.c
vendored
Normal file
29
vendors/ffi_fp_struct/ffi_fp_struct.c
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "ffi_fp_struct.h"
|
||||
|
||||
FQuad ffi_fquad_make(float a, float b, float c, float d) {
|
||||
FQuad r = { a, b, c, d };
|
||||
return r;
|
||||
}
|
||||
|
||||
FQuad ffi_fquad_reverse(FQuad v) {
|
||||
FQuad r = { v.d, v.c, v.b, v.a };
|
||||
return r;
|
||||
}
|
||||
|
||||
float ffi_fquad_sum(FQuad v) {
|
||||
return v.a + v.b + v.c + v.d;
|
||||
}
|
||||
|
||||
DQuad ffi_dquad_make(double a, double b, double c, double d) {
|
||||
DQuad r = { a, b, c, d };
|
||||
return r;
|
||||
}
|
||||
|
||||
DQuad ffi_dquad_reverse(DQuad v) {
|
||||
DQuad r = { v.d, v.c, v.b, v.a };
|
||||
return r;
|
||||
}
|
||||
|
||||
double ffi_dquad_sum(DQuad v) {
|
||||
return v.a + v.b + v.c + v.d;
|
||||
}
|
||||
20
vendors/ffi_fp_struct/ffi_fp_struct.h
vendored
Normal file
20
vendors/ffi_fp_struct/ffi_fp_struct.h
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
// Focused FP-aggregate (HFA) FFI baselines. Distinct from the int-aggregate
|
||||
// register-coercion paths because all-float / all-double structs of ≤4 fields
|
||||
// stay as struct values in LLVM and are passed/returned via the float
|
||||
// register file (AAPCS64 v0..v3; SysV AMD64 xmm0..xmm7). This was the
|
||||
// `UIEdgeInsets`-as-f32-vs-f64 landmine — pinned here so a future ABI rule
|
||||
// change that wrecks the FP path fails this test directly.
|
||||
//
|
||||
// FQuad — 16 B, four float (small HFA; same slot as Vec4f)
|
||||
// DQuad — 32 B, four double (UIEdgeInsets-shape HFA)
|
||||
|
||||
typedef struct { float a; float b; float c; float d; } FQuad;
|
||||
typedef struct { double a; double b; double c; double d; } DQuad;
|
||||
|
||||
FQuad ffi_fquad_make (float a, float b, float c, float d);
|
||||
FQuad ffi_fquad_reverse(FQuad v);
|
||||
float ffi_fquad_sum (FQuad v);
|
||||
|
||||
DQuad ffi_dquad_make (double a, double b, double c, double d);
|
||||
DQuad ffi_dquad_reverse(DQuad v);
|
||||
double ffi_dquad_sum (DQuad v);
|
||||
Reference in New Issue
Block a user