@@ -104,11 +104,16 @@ namespace pointer_types {
104
104
}
105
105
106
106
namespace {
107
- template <typename T>
108
- constexpr size_t getAlignment () { return alignof (T); }
107
+ template <typename T>
108
+ struct BuiltinType {
109
+ static constexpr const size_t Alignment = alignof (T);
110
+ };
109
111
110
- #define SET_FIXED_ALIGNMENT (Type, Align ) \
111
- template <> constexpr size_t getAlignment<Type>() { return Align; }
112
+ #define SET_FIXED_ALIGNMENT (Type, Align ) \
113
+ template <> \
114
+ struct BuiltinType <Type> { \
115
+ static constexpr const size_t Alignment = Align; \
116
+ };
112
117
113
118
SET_FIXED_ALIGNMENT (uint8_t , 1 )
114
119
SET_FIXED_ALIGNMENT (uint16_t , 2 )
@@ -120,27 +125,40 @@ template<> constexpr size_t getAlignment<Type>() { return Align; }
120
125
121
126
#undef SET_FIXED_ALIGNMENT
122
127
123
- template <typename T, unsigned N>
124
- struct SwiftVecT {
125
- typedef T type __attribute__ ((ext_vector_type (N)));
128
+ template <typename T, unsigned N>
129
+ struct SIMDVector {
130
+ using Type = T __attribute__ ((__ext_vector_type__ (N)));
126
131
};
127
132
128
- template <typename T, unsigned N>
129
- using SwiftVec = typename SwiftVecT<T, N>::type;
133
+ template <>
134
+ struct SIMDVector <float , 3 > {
135
+ using Type = float __attribute__ ((__ext_vector_type__(4 )));
136
+ };
137
+
138
+ template <>
139
+ struct SIMDVector <double , 3 > {
140
+ using Type = double __attribute__ ((__ext_vector_type__(4 )));
141
+ };
142
+
143
+ template <typename T, unsigned N>
144
+ using SIMDVectorType = typename SIMDVector<T, N>::Type;
130
145
}
131
146
132
- #define BUILTIN_TYPE (Symbol, Name ) \
133
- const ValueWitnessTable swift::VALUE_WITNESS_SYM (Symbol) = \
134
- ValueWitnessTableForBox<NativeBox<ctypes::Symbol, \
135
- getAlignment<ctypes::Symbol>()>>::table;
147
+ #define BUILTIN_TYPE (Symbol, Name ) \
148
+ const ValueWitnessTable swift::VALUE_WITNESS_SYM (Symbol) = \
149
+ ValueWitnessTableForBox<NativeBox<ctypes::Symbol, \
150
+ BuiltinType<ctypes::Symbol>::Alignment>>::table;
151
+
136
152
#define BUILTIN_POINTER_TYPE (Symbol, Name ) \
137
- const ExtraInhabitantsValueWitnessTable swift::VALUE_WITNESS_SYM (Symbol) = \
153
+ const ExtraInhabitantsValueWitnessTable swift::VALUE_WITNESS_SYM (Symbol) = \
138
154
ValueWitnessTableForBox<pointer_types::Symbol>::table;
139
- #define BUILTIN_VECTOR_TYPE (ElementSymbol, _, Width ) \
140
- const ValueWitnessTable \
141
- swift::VALUE_WITNESS_SYM (VECTOR_BUILTIN_SYMBOL_NAME(ElementSymbol,Width)) = \
142
- ValueWitnessTableForBox<NativeBox<SwiftVec<ctypes::ElementSymbol, \
143
- Width>>>::table;
155
+
156
+ #define BUILTIN_VECTOR_TYPE (ElementSymbol, _, Width ) \
157
+ const ValueWitnessTable \
158
+ swift::VALUE_WITNESS_SYM (VECTOR_BUILTIN_SYMBOL_NAME(ElementSymbol,Width)) = \
159
+ ValueWitnessTableForBox<NativeBox<SIMDVectorType<ctypes::ElementSymbol, \
160
+ Width>>>::table;
161
+
144
162
#include " swift/Runtime/BuiltinTypes.def"
145
163
146
164
// / The value-witness table for pointer-aligned unmanaged pointer types.
0 commit comments