Skip to content

Commit

Permalink
Remove specializations for vector_storage that add fields (x, y, z,…
Browse files Browse the repository at this point in the history
… w) since this is not supported on all compilers
  • Loading branch information
stijnh committed Oct 6, 2023
1 parent fcfd9c1 commit 0eeed0c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 190 deletions.
104 changes: 10 additions & 94 deletions include/kernel_float/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,126 +21,42 @@ struct alignas(Alignment) aligned_array {
T items_[N] = {};
};

template<typename T, size_t Alignment>
struct aligned_array<T, 0, Alignment> {
KERNEL_FLOAT_INLINE
T* data() {
while (true)
;
}

KERNEL_FLOAT_INLINE
const T* data() const {
while (true)
;
}
};

template<typename T, size_t Alignment>
struct alignas(Alignment) aligned_array<T, 1, Alignment> {
KERNEL_FLOAT_INLINE
aligned_array(T value = {}) : x(value) {}
aligned_array(T item = {}) : item_(item) {}

KERNEL_FLOAT_INLINE
operator T() const {
return x;
}

KERNEL_FLOAT_INLINE
T* data() {
return &x;
}

KERNEL_FLOAT_INLINE
const T* data() const {
return &x;
}

T x;
};

template<typename T, size_t Alignment>
struct alignas(Alignment) aligned_array<T, 2, Alignment> {
KERNEL_FLOAT_INLINE
aligned_array(T x, T y) : x(x), y(y) {}

KERNEL_FLOAT_INLINE
aligned_array() : aligned_array(T {}, T {}) {}

KERNEL_FLOAT_INLINE
T* data() {
return items;
return item_;
}

KERNEL_FLOAT_INLINE
const T* data() const {
return items;
}

union {
T items[2];
struct {
T x;
T y;
};
};
};

template<typename T, size_t Alignment>
struct alignas(Alignment) aligned_array<T, 3, Alignment> {
KERNEL_FLOAT_INLINE
aligned_array(T x, T y, T z) : x(x), y(y), z(z) {}

KERNEL_FLOAT_INLINE
aligned_array() : aligned_array(T {}, T {}, T {}) {}

KERNEL_FLOAT_INLINE
T* data() {
return items;
return &item_;
}

KERNEL_FLOAT_INLINE
const T* data() const {
return items;
return &item_;
}

union {
T items[3];
struct {
T x;
T y;
T z;
};
};
T item_ = {};
};

template<typename T, size_t Alignment>
struct alignas(Alignment) aligned_array<T, 4, Alignment> {
KERNEL_FLOAT_INLINE
aligned_array(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {}

KERNEL_FLOAT_INLINE
aligned_array() : aligned_array(T {}, T {}, T {}, T {}) {}

struct aligned_array<T, 0, Alignment> {
KERNEL_FLOAT_INLINE
T* data() {
return items;
while (true)
;
}

KERNEL_FLOAT_INLINE
const T* data() const {
return items;
while (true)
;
}

union {
T items[4];
struct {
T x;
T y;
T z;
T w;
};
};
};

KERNEL_FLOAT_INLINE
Expand Down
108 changes: 12 additions & 96 deletions single_include/kernel_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

//================================================================================
// this file has been auto-generated, do not modify its contents!
// date: 2023-09-28 12:12:55.542179
// git hash: 0ae5853b782118d9842541588429b4aec7ff186a
// date: 2023-10-06 16:02:20.461619
// git hash: d578b7a87ead79baf78e181e8fbe14c03ea3f9a6
//================================================================================

#ifndef KERNEL_FLOAT_MACROS_H
Expand Down Expand Up @@ -365,126 +365,42 @@ struct alignas(Alignment) aligned_array {
T items_[N] = {};
};

template<typename T, size_t Alignment>
struct aligned_array<T, 0, Alignment> {
KERNEL_FLOAT_INLINE
T* data() {
while (true)
;
}

KERNEL_FLOAT_INLINE
const T* data() const {
while (true)
;
}
};

template<typename T, size_t Alignment>
struct alignas(Alignment) aligned_array<T, 1, Alignment> {
KERNEL_FLOAT_INLINE
aligned_array(T value = {}) : x(value) {}
aligned_array(T item = {}) : item_(item) {}

KERNEL_FLOAT_INLINE
operator T() const {
return x;
return item_;
}

KERNEL_FLOAT_INLINE
T* data() {
return &x;
return &item_;
}

KERNEL_FLOAT_INLINE
const T* data() const {
return &x;
return &item_;
}

T x;
T item_ = {};
};

template<typename T, size_t Alignment>
struct alignas(Alignment) aligned_array<T, 2, Alignment> {
KERNEL_FLOAT_INLINE
aligned_array(T x, T y) : x(x), y(y) {}

KERNEL_FLOAT_INLINE
aligned_array() : aligned_array(T {}, T {}) {}

KERNEL_FLOAT_INLINE
T* data() {
return items;
}

KERNEL_FLOAT_INLINE
const T* data() const {
return items;
}

union {
T items[2];
struct {
T x;
T y;
};
};
};

template<typename T, size_t Alignment>
struct alignas(Alignment) aligned_array<T, 3, Alignment> {
KERNEL_FLOAT_INLINE
aligned_array(T x, T y, T z) : x(x), y(y), z(z) {}

KERNEL_FLOAT_INLINE
aligned_array() : aligned_array(T {}, T {}, T {}) {}

KERNEL_FLOAT_INLINE
T* data() {
return items;
}

KERNEL_FLOAT_INLINE
const T* data() const {
return items;
}

union {
T items[3];
struct {
T x;
T y;
T z;
};
};
};

template<typename T, size_t Alignment>
struct alignas(Alignment) aligned_array<T, 4, Alignment> {
KERNEL_FLOAT_INLINE
aligned_array(T x, T y, T z, T w) : x(x), y(y), z(z), w(w) {}

KERNEL_FLOAT_INLINE
aligned_array() : aligned_array(T {}, T {}, T {}, T {}) {}

struct aligned_array<T, 0, Alignment> {
KERNEL_FLOAT_INLINE
T* data() {
return items;
while (true)
;
}

KERNEL_FLOAT_INLINE
const T* data() const {
return items;
while (true)
;
}

union {
T items[4];
struct {
T x;
T y;
T z;
T w;
};
};
};

KERNEL_FLOAT_INLINE
Expand Down

0 comments on commit 0eeed0c

Please sign in to comment.