28 #ifndef __ARCH_ARM_AAPCS64_HH__
29 #define __ARCH_ARM_AAPCS64_HH__
33 #include <type_traits>
75 template <
typename T,
typename Enabled=
void>
78 template <
typename E,
size_t N>
80 typename
std::enable_if<
81 (std::is_integral<E>::value || std::is_floating_point<E>::value) &&
82 (sizeof(E) * N == 8 || sizeof(E) * N == 16)>
::type> :
90 template <
typename T,
typename Enabled=
void>
95 (std::is_array<T>::value ||
96 std::is_class<T>::value ||
97 std::is_union<T>::value) &&
99 !IsVarArgs<T>::value &&
101 !IsAapcs64ShortVector<T>::value
102 >
::type> :
public std::true_type
114 template <
typename T,
typename Enabled=
void>
117 template <
typename E,
size_t N>
119 typename
std::enable_if<std::is_floating_point<E>::value &&
120 N <= 4>::type> :
public std::true_type
127 template <
typename T,
typename Enabled=
void>
128 struct IsAapcs64Hva :
public std::false_type {};
130 template <
typename E,
size_t N>
131 struct IsAapcs64Hva<
E[N],
132 typename
std::enable_if<IsAapcs64ShortVector<E>::value &&
133 N <= 4>::type> :
public std::true_type
137 template <
typename T,
typename Enabled=
void>
138 struct IsAapcs64Hxa :
public std::false_type {};
140 template <
typename T>
141 struct IsAapcs64Hxa<T, typename
std::enable_if<
142 IsAapcs64Hfa<T>::value || IsAapcs64Hva<T>::value>
::type> :
143 public std::true_type
146 struct Aapcs64ArgumentBase
148 template <
typename T>
153 size_t align = std::max<size_t>(8,
alignof(T));
155 size_t size =
roundUp(
sizeof(T), 8);
176 template <
typename Float>
177 struct Argument<
Aapcs64, Float, typename
std::enable_if<
178 std::is_floating_point<Float>::value ||
179 IsAapcs64ShortVector<Float>::value>
::type> :
180 public Aapcs64ArgumentBase
190 return loadFromStack<Float>(tc, state);
194 template <
typename Float>
196 std::is_floating_point<Float>::value ||
197 IsAapcs64ShortVector<Float>::value>
::type>
204 reg.laneView<Float, 0>() =
f;
215 template <
typename Integer>
217 std::is_integral<Integer>::value && (sizeof(Integer) <= 8)
218 >::type> :
public Aapcs64ArgumentBase
229 return loadFromStack<Integer>(tc, state);
233 template <
typename Integer>
234 struct Argument<
Aapcs64, Integer, typename
std::enable_if<
235 std::is_integral<Integer>::value && (sizeof(Integer) > 8)
236 >
::type> :
public Aapcs64ArgumentBase
241 if (
alignof(Integer) == 16 && (state.
ngrn % 2))
244 if (
sizeof(Integer) == 16 && state.
ngrn + 1 <= state.
MAX_GRN) {
254 return loadFromStack<Integer>(tc, state);
258 template <
typename Integer>
260 std::is_integral<Integer>::value && (sizeof(Integer) <= 8)
270 template <
typename Integer>
272 std::is_integral<Integer>::value && (sizeof(Integer) > 8)
289 template <
typename T>
292 template <
typename E,
size_t N>
295 template <
typename HA>
297 IsAapcs64Hxa<HA>::value>
::type> :
public Aapcs64ArgumentBase
303 constexpr
size_t Count =
sizeof(HA) /
sizeof(Elem);
307 for (
int i = 0;
i < Count;
i++)
315 return loadFromStack<HA>(tc, state);
319 template <
typename HA>
321 typename
std::enable_if<IsAapcs64Hxa<HA>::value>
::type>
327 constexpr
size_t Count =
sizeof(HA) /
sizeof(Elem);
329 for (
int i = 0;
i < Count;
i++)
339 template <
typename Composite>
341 IsAapcs64Composite<Composite>::value && !IsAapcs64Hxa<Composite>::value
342 >
::type> :
public Aapcs64ArgumentBase
347 if (
sizeof(Composite) > 16) {
358 size_t bytes =
sizeof(Composite);
359 using Chunk = uint64_t;
361 const int chunk_size =
sizeof(Chunk);
362 const int regs = (bytes + chunk_size - 1) / chunk_size;
366 alignas(
alignof(Composite)) uint8_t buf[bytes];
367 for (
int i = 0;
i < regs;
i++) {
370 size_t to_copy = std::min<size_t>(bytes, chunk_size);
371 memcpy(buf +
i * chunk_size, &
val, to_copy);
380 return loadFromStack<Composite>(tc, state);
384 template <
typename Composite>
386 IsAapcs64Composite<Composite>::value && !IsAapcs64Hxa<Composite>::value
392 if (
sizeof(Composite) > 16) {
401 size_t bytes =
sizeof(Composite);
402 using Chunk = uint64_t;
404 const int chunk_size =
sizeof(Chunk);
405 const int regs = (bytes + chunk_size - 1) / chunk_size;
408 uint8_t *buf = (uint8_t *)&
cp;
409 for (
int i = 0;
i < regs;
i++) {
410 size_t to_copy = std::min<size_t>(bytes, chunk_size);
413 memcpy(&
val, buf, to_copy);
426 #endif // __ARCH_ARM_AAPCS64_HH__