solidc
Robust collection of general-purpose cross-platform C libraries and data structures designed for rapid and safe development in C
Loading...
Searching...
No Matches
Macros
simd.h File Reference

Portable Single Instruction Multiple Data (SIMD) Intrinsics Wrapper. More...

#include "align.h"
#include <math.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for simd.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define simd_swizzle(v, x, y, z, w)   ((simd_vec_t){{(v).f[(x)], (v).f[(y)], (v).f[(z)], (v).f[(w)]}})
 Rearranges vector components.
 
#define simd_transpose4(r0, r1, r2, r3)
 Transposes a 4x4 matrix defined by 4 row/col vectors in-place.
 

Detailed Description

Portable Single Instruction Multiple Data (SIMD) Intrinsics Wrapper.

This header provides a unified abstraction layer over hardware-accelerated vector operations. It automatically detects the target architecture and maps abstract vector types to the underlying hardware registers.

Supported Backends:

Design Philosophy:

Usage Example:

simd_vec_t pos_a = simd_set(10.0f, 20.0f, 30.0f, 1.0f);
simd_vec_t pos_b = simd_set(5.0f, 5.0f, 5.0f, 0.0f);
// Vertical addition (happens in one CPU cycle equivalent)
simd_vec_t result = simd_add(pos_a, pos_b);
// Dot product
float dist_sq = simd_dot3(result, result);

Definition in file simd.h.

Macro Definition Documentation

◆ simd_swizzle

#define simd_swizzle (   v,
  x,
  y,
  z,
 
)    ((simd_vec_t){{(v).f[(x)], (v).f[(y)], (v).f[(z)], (v).f[(w)]}})

Rearranges vector components.

Usage: simd_vec_t result = simd_swizzle(v, SIMD_Y, SIMD_X, SIMD_W, SIMD_Z);

Note
This MUST be a macro because x86 intrinsics require compile-time constants.

Definition at line 1059 of file simd.h.