28#ifndef __ARCH_ARM_AAPCS64_HH__
29#define __ARCH_ARM_AAPCS64_HH__
65 nsaa(tc->getReg(ArmISA::int_reg::Spx))
81template <
typename T,
typename Enabled=
void>
84template <
typename E,
size_t N>
86 typename
std::enable_if_t<
87 (std::is_integral_v<E> || std::is_floating_point_v<E>) &&
88 (sizeof(E) * N == 8 || sizeof(E) * N == 16)>> :
99template <
typename T,
typename Enabled=
void>
104 (std::is_array_v<T> || std::is_class_v<T> || std::is_union_v<T>) &&
108 !IsAapcs64ShortVectorV<T>
109 >> :
public std::true_type
124template <
typename T,
typename Enabled=
void>
127template <
typename E,
size_t N>
129 typename
std::enable_if_t<std::is_floating_point_v<E> && N <= 4>> :
130 public std::true_type
140template <
typename T,
typename Enabled=
void>
143template <
typename E,
size_t N>
145 typename
std::enable_if_t<IsAapcs64ShortVectorV<E> && N <= 4>> :
146 public std::true_type
153template <
typename T,
typename Enabled=
void>
158 IsAapcs64HfaV<T> || IsAapcs64HvaV<T>>> :
159 public std::true_type
167 template <
typename T>
172 size_t align = std::max<size_t>(8,
alignof(T));
174 size_t size =
roundUp(
sizeof(T), 8);
195template <
typename Float>
197 std::is_floating_point_v<Float> || IsAapcs64ShortVectorV<Float>>> :
207 return vc.
as<Float>()[0];
210 return loadFromStack<Float>(tc,
state);
214template <
typename Float>
216 std::is_floating_point_v<Float> || IsAapcs64ShortVectorV<Float>>>
224 reg.as<Float>()[0] =
f;
235template <
typename Integer>
237 std::is_integral_v<Integer> && (sizeof(Integer) <= 8)>> :
249 return loadFromStack<Integer>(tc,
state);
253template <
typename Integer>
255 std::is_integral_v<Integer> && (sizeof(Integer) > 8)>> :
261 if (
alignof(Integer) == 16 && (
state.ngrn % 2))
264 if (
sizeof(Integer) == 16 &&
state.ngrn + 1 <=
state.MAX_GRN) {
274 return loadFromStack<Integer>(tc,
state);
278template <
typename Integer>
280 std::is_integral_v<Integer> && (sizeof(Integer) <= 8)>>
289template <
typename Integer>
291 std::is_integral_v<Integer> && (sizeof(Integer) > 8)>>
310template <
typename E,
size_t N>
313template <
typename HA>
321 constexpr size_t Count =
sizeof(HA) /
sizeof(Elem);
323 if (
state.nsrn + Count - 1 <=
state.MAX_SRN) {
325 for (
int i = 0;
i < Count;
i++)
333 return loadFromStack<HA>(tc,
state);
337template <
typename HA>
344 constexpr size_t Count =
sizeof(HA) /
sizeof(Elem);
346 for (
int i = 0;
i < Count;
i++)
356template <
typename Composite>
358 IsAapcs64CompositeV<Composite> && !IsAapcs64HxaV<Composite>>> :
364 if (
sizeof(Composite) > 16) {
375 size_t bytes =
sizeof(Composite);
376 using Chunk = uint64_t;
378 const int chunk_size =
sizeof(Chunk);
379 const int regs = (bytes + chunk_size - 1) / chunk_size;
383 alignas(
alignof(Composite)) uint8_t buf[bytes];
384 for (
int i = 0;
i < regs;
i++) {
387 size_t to_copy = std::min<size_t>(bytes, chunk_size);
388 memcpy(buf +
i * chunk_size, &
val, to_copy);
397 return loadFromStack<Composite>(tc,
state);
401template <
typename Composite>
403 IsAapcs64CompositeV<Composite> && !IsAapcs64HxaV<Composite>>>
408 if (
sizeof(Composite) > 16) {
417 size_t bytes =
sizeof(Composite);
418 using Chunk = uint64_t;
420 const int chunk_size =
sizeof(Chunk);
421 const int regs = (bytes + chunk_size - 1) / chunk_size;
424 uint8_t *buf = (uint8_t *)&cp;
425 for (
int i = 0;
i < regs;
i++) {
426 size_t to_copy = std::min<size_t>(bytes, chunk_size);
429 memcpy(&
val, buf, to_copy);
Register ID: describe an architectural register with its class and index.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
virtual RegVal getReg(const RegId ®) const
virtual void setReg(const RegId ®, RegVal val)
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
VecElem * as()
View interposers.
static constexpr T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
static RegId x(unsigned index)
ByteOrder byteOrder(const ThreadContext *tc)
constexpr RegClass intRegClass
constexpr RegClass vecRegClass
constexpr bool IsAapcs64CompositeV
constexpr bool IsAapcs64HvaV
constexpr bool IsAapcs64HfaV
constexpr bool IsAapcs64HxaV
constexpr bool IsAapcs64ShortVectorV
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
T gtoh(T value, ByteOrder guest_byte_order)
T htog(T value, ByteOrder guest_byte_order)
Overload hash function for BasicBlockRange type.
State(const ThreadContext *tc)
static T loadFromStack(ThreadContext *tc, Aapcs64::State &state)
static Composite get(ThreadContext *tc, Aapcs64::State &state)
static Float get(ThreadContext *tc, Aapcs64::State &state)
static HA get(ThreadContext *tc, Aapcs64::State &state)
static Integer get(ThreadContext *tc, Aapcs64::State &state)
static Integer get(ThreadContext *tc, Aapcs64::State &state)
static void store(ThreadContext *tc, const Composite &c)
static void store(ThreadContext *tc, const Float &f)
static HA store(ThreadContext *tc, const HA &ha)
static void store(ThreadContext *tc, const Integer &i)
static void store(ThreadContext *tc, const Integer &i)