| 1 | /* |
| 2 | * Copyright (C) 2011 Gilead Kutnick "Exophase" <exophase@gmail.com> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License as |
| 6 | * published by the Free Software Foundation; either version 2 of |
| 7 | * the License, or (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * General Public License for more details. |
| 13 | */ |
| 14 | |
| 15 | #ifndef VECTOR_TYPES |
| 16 | #define VECTOR_TYPES |
| 17 | |
| 18 | #include <stdint.h> |
| 19 | |
| 20 | typedef int8_t s8; |
| 21 | typedef uint8_t u8; |
| 22 | typedef int16_t s16; |
| 23 | typedef uint16_t u16; |
| 24 | typedef int32_t s32; |
| 25 | typedef uint32_t u32; |
| 26 | typedef int64_t s64; |
| 27 | typedef uint64_t u64; |
| 28 | |
| 29 | #define build_vector_type_pair(sign, size, count, count_x2) \ |
| 30 | typedef struct \ |
| 31 | { \ |
| 32 | sign##size e[count]; \ |
| 33 | } vec_##count##x##size##sign; \ |
| 34 | \ |
| 35 | typedef struct \ |
| 36 | { \ |
| 37 | union \ |
| 38 | { \ |
| 39 | sign##size e[count_x2]; \ |
| 40 | struct \ |
| 41 | { \ |
| 42 | vec_##count##x##size##sign low; \ |
| 43 | vec_##count##x##size##sign high; \ |
| 44 | }; \ |
| 45 | }; \ |
| 46 | } vec_##count_x2##x##size##sign \ |
| 47 | |
| 48 | #define build_vector_types(sign) \ |
| 49 | build_vector_type_pair(sign, 8, 8, 16); \ |
| 50 | build_vector_type_pair(sign, 16, 4, 8); \ |
| 51 | build_vector_type_pair(sign, 32, 2, 4); \ |
| 52 | build_vector_type_pair(sign, 64, 1, 2) \ |
| 53 | |
| 54 | build_vector_types(u); |
| 55 | build_vector_types(s); |
| 56 | |
| 57 | #endif // VECTOR_TYPES |