28#ifndef __ARCH_ARM_AAPCS32_HH__
29#define __ARCH_ARM_AAPCS32_HH__
80template <
typename T,
typename Enabled=
void>
85 (std::is_array_v<T> || std::is_class_v<T> || std::is_union_v<T>) &&
88 >> :
public std::true_type
99template <
typename T, std::
size_t count,
typename Enabled=
void>
105template <
typename E,
size_t N>
114 template <
typename T>
121 size_t align = std::max<size_t>(4,
alignof(T));
123 size_t size =
roundUp(
sizeof(T), 4);
144template <
typename Integer>
146 std::is_integral_v<Integer> && (sizeof(Integer) < sizeof(uint32_t))>>
151 uint32_t
val = std::is_signed_v<Integer> ?
157template <
typename Integer>
159 std::is_integral_v<Integer> && (sizeof(Integer) == sizeof(uint32_t))>>
168template <
typename Integer>
170 std::is_integral_v<Integer> && (sizeof(Integer) == sizeof(uint64_t))>>
185template <
typename Integer>
187 std::is_integral_v<Integer> && (sizeof(Integer) <= sizeof(uint32_t))
204template <
typename Integer>
206 std::is_integral_v<Integer> && (sizeof(Integer) > sizeof(uint32_t))
212 if (
alignof(Integer) == 8 && (state.
ncrn % 2))
215 if (
sizeof(Integer) ==
sizeof(uint64_t) &&
227 return low | (high << 32);
242template <
typename Float>
244 std::is_floating_point_v<Float>>>
254template <
typename Float>
261 if (
sizeof(Float) ==
sizeof(uint32_t)) {
276template <
typename Composite>
278 IsAapcs32CompositeV<Composite>>>
284 if (
sizeof(Composite) <=
sizeof(uint32_t)) {
287 memcpy((
void *)&
val, (
void *)&
cp,
sizeof(Composite));
299 if (
sizeof(Composite) >
sizeof(uint32_t))
304template <
typename Composite>
306 IsAapcs32CompositeV<Composite>>> :
312 size_t bytes =
sizeof(Composite);
313 using Chunk = uint32_t;
315 const size_t chunk_size =
sizeof(Chunk);
316 const size_t regs = (bytes + chunk_size - 1) / chunk_size;
318 if (bytes <= chunk_size) {
320 alignas(
alignof(Composite)) uint32_t
val =
327 if (
alignof(Composite) == 8 && (state.
ncrn % 2))
331 std::align_val_t align{
alignof(Composite)};
332 auto buf = std::unique_ptr<uint8_t[]>(
new (align) uint8_t[bytes]);
333 for (
int i = 0;
i < regs;
i++) {
336 size_t to_copy = std::min(bytes, chunk_size);
337 memcpy(buf.get() +
i * chunk_size, &
val, to_copy);
344 std::align_val_t align{
alignof(Composite)};
345 auto buf = std::unique_ptr<uint8_t[]>(
new (align) uint8_t[bytes]);
351 size_t to_copy = std::min(bytes, chunk_size);
352 memcpy(buf.get() +
offset, &
val, to_copy);
363 state.
nsaa, buf.get(), bytes);
394 std::array<bool, 16>
s;
395 std::array<bool, 8>
d;
407 for (
int i = 0;
i <=
s.size() -
count;
i++) {
412 if (
i - last + 1 ==
count) {
413 for (
int j = 0; j <
count; j++) {
415 d[(last + j) / 2] =
true;
429 for (
int i = 0;
i <=
d.size() -
count;
i++) {
434 if (
i - last + 1 ==
count) {
435 for (
int j = 0; j <
count; j++) {
437 s[(last + j) * 2] =
true;
438 s[(last + j) * 2 + 1] =
true;
457template <
typename Integer>
459 std::is_integral_v<Integer>>> :
public Result<Aapcs32, Integer>
462template <
typename Integer>
464 std::is_integral_v<Integer>>> :
public Argument<Aapcs32, Integer>
472template <
typename Float>
474 std::is_floating_point_v<Float>>>
487 for (
int chunk = 0; chunk < chunks; chunk++)
492template <
typename Float>
511 for (
int chunk = 0; chunk < chunks; chunk++)
523template <
typename Composite>
525 IsAapcs32CompositeV<Composite> &&
526 !IsAapcs32HomogeneousAggregateV<Composite>>> :
527 public Result<Aapcs32, Composite>
530template <
typename Composite>
532 IsAapcs32CompositeV<Composite> &&
533 !IsAapcs32HomogeneousAggregateV<Composite>>> :
545template <
typename E,
size_t N>
548template <
typename HA>
550 IsAapcs32HomogeneousAggregateV<HA>>> :
557 constexpr size_t Count =
sizeof(HA) /
sizeof(Elem);
558 return state.
variadic || !std::is_floating_point_v<Elem> ||
566 constexpr size_t Count =
sizeof(HA) /
sizeof(Elem);
573 constexpr int lane_per_reg = 16 /
sizeof(Elem);
575 for (
int i = 0;
i < Count;
i++) {
577 const int reg =
index / lane_per_reg;
578 const int lane =
index % lane_per_reg;
583 ha[
i] =
val.as<Elem>()[lane];
599template <
typename HA>
601 typename
std::enable_if_t<IsAapcs32HomogeneousAggregateV<HA>>>
607 constexpr size_t Count =
sizeof(HA) /
sizeof(Elem);
608 return state.
variadic || !std::is_floating_point_v<Elem> ||
616 constexpr size_t Count =
sizeof(HA) /
sizeof(Elem);
623 constexpr int lane_per_reg = 16 /
sizeof(Elem);
624 for (
int i = 0;
i < Count;
i++) {
625 const int reg =
i / lane_per_reg;
626 const int lane =
i % lane_per_reg;
631 val.as<Elem>()[lane] =
ha[
i];
649template <
typename ...Types>
This object is a proxy for a port or other object which implements the functional response protocol,...
void readBlob(Addr addr, void *p, uint64_t size) const
Higher level interfaces based on the above.
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)
This proxy attempts to translate virtual addresses using the TLBs.
static constexpr T roundUp(const T &val, const U &align)
This function is used to align addresses in memory.
constexpr uint64_t sext(uint64_t val)
Sign-extend an N-bit value to 64 bits.
ByteOrder byteOrder(const ThreadContext *tc)
constexpr RegClass vecElemClass
constexpr RegClass intRegClass
gem5::VecRegContainer< NumVecElemPerVecReg *sizeof(VecElem)> VecRegContainer
constexpr RegClass vecRegClass
constexpr bool IsAapcs32CompositeV
constexpr bool IsAapcs32HomogeneousAggregateV
static void storeResult(ThreadContext *tc, const Ret &ret, typename ABI::State &state)
T[count] Aapcs32HomogeneousAggregate
static Arg getArgument(ThreadContext *tc, typename ABI::State &state)
Copyright (c) 2024 Arm Limited All rights reserved.
static uint64_t floatToBits(double val)
ProxyPtr< T, SETranslatingPortProxy > VPtr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
T gtoh(T value, ByteOrder guest_byte_order)
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
static double bitsToFloat(uint64_t val)
T htog(T value, ByteOrder guest_byte_order)
static double bitsToFloat64(uint64_t val)
static float bitsToFloat32(uint32_t val)
ConstProxyPtr< T, SETranslatingPortProxy > ConstVPtr
Overload hash function for BasicBlockRange type.
PortProxy Object Declaration.
State(const ThreadContext *tc)
int allocate(double, int count)
int allocate(float, int count)
State(const ThreadContext *tc)
static T loadFromStack(ThreadContext *tc, Aapcs32::State &state)
static Float get(ThreadContext *tc, Aapcs32Vfp::State &state)
static HA get(ThreadContext *tc, Aapcs32Vfp::State &state)
static bool useBaseABI(Aapcs32Vfp::State &state)
static void prepare(ThreadContext *tc, Aapcs32Vfp::State &state)
static VarArgs< Types... > get(ThreadContext *tc, typename Aapcs32Vfp::State &state)
static Composite get(ThreadContext *tc, Aapcs32::State &state)
static Float get(ThreadContext *tc, Aapcs32::State &state)
static Integer get(ThreadContext *tc, Aapcs32::State &state)
static Integer get(ThreadContext *tc, Aapcs32::State &state)
static void store(ThreadContext *tc, const Float &f, Aapcs32Vfp::State &state)
static void prepare(ThreadContext *tc, Aapcs32Vfp::State &state)
static bool useBaseABI(Aapcs32Vfp::State &state)
static HA store(ThreadContext *tc, const HA &ha, Aapcs32Vfp::State &state)
static void store(ThreadContext *tc, const Composite &composite, Aapcs32::State &state)
static void prepare(ThreadContext *tc, Aapcs32::State &state)
static void store(ThreadContext *tc, const Float &f, Aapcs32::State &state)
static void store(ThreadContext *tc, const Integer &i)
static void store(ThreadContext *tc, const Integer &i)
static void store(ThreadContext *tc, const Integer &i)