sim: Get rid of the IsConforming type trait template.
The idea of this template was to distinguish types which should grow/shrink based on the native size of the ABI in question. Or in other words, if the ABI was 32 bit, the type should also be 32 bit, or 64 bit and 64 bit. Unfortunately, I had intended for Addr to be a conforming type (since local pointers would be conforming), but uint64_t not to be. Since Addr is defined as a typedef of uint64_t, the compiler would make *both* types conforming, giving incorrect behavior on 32 bit systems. Local pointers will need to be handled in a different way, likely with the VPtr template, so that they will be treated correctly and not like an explicitly 64 bit data type. Change-Id: Idfdd5351260b48bb531a1926b93e0478a297826d Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/40495 Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -160,9 +160,7 @@ struct Result<Aapcs32, Integer, typename std::enable_if_t<
|
||||
static void
|
||||
store(ThreadContext *tc, const Integer &i)
|
||||
{
|
||||
if (std::is_same<Integer, Addr>::value) {
|
||||
tc->setIntReg(ArmISA::INTREG_R0, (uint32_t)i);
|
||||
} else if (ArmISA::byteOrder(tc) == ByteOrder::little) {
|
||||
if (ArmISA::byteOrder(tc) == ByteOrder::little) {
|
||||
tc->setIntReg(ArmISA::INTREG_R0, (uint32_t)(i >> 0));
|
||||
tc->setIntReg(ArmISA::INTREG_R1, (uint32_t)(i >> 32));
|
||||
} else {
|
||||
@@ -199,11 +197,6 @@ struct Argument<Aapcs32, Integer, typename std::enable_if_t<
|
||||
static Integer
|
||||
get(ThreadContext *tc, Aapcs32::State &state)
|
||||
{
|
||||
if (std::is_same<Integer, Addr>::value &&
|
||||
state.ncrn <= state.MAX_CRN) {
|
||||
return tc->readIntReg(state.ncrn++);
|
||||
}
|
||||
|
||||
if (alignof(Integer) == 8 && (state.ncrn % 2))
|
||||
state.ncrn++;
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ template <typename ABI, typename Arg>
|
||||
struct Argument<ABI, Arg,
|
||||
typename std::enable_if_t<
|
||||
std::is_base_of<ArmISA::RegABI32, ABI>::value &&
|
||||
std::is_integral<Arg>::value &&
|
||||
ABI::template IsWide<Arg>::value>>
|
||||
{
|
||||
static Arg
|
||||
|
||||
@@ -105,6 +105,7 @@ struct Result<ABI, SyscallReturn,
|
||||
template <typename Arg>
|
||||
struct Argument<SparcISA::SEWorkload::SyscallABI32, Arg,
|
||||
typename std::enable_if_t<
|
||||
std::is_integral<Arg>::value &&
|
||||
SparcISA::SEWorkload::SyscallABI32::IsWide<Arg>::value>>
|
||||
{
|
||||
using ABI = SparcISA::SEWorkload::SyscallABI32;
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace GuestABI
|
||||
|
||||
template <typename Arg>
|
||||
struct Argument<X86ISA::EmuLinux::SyscallABI32, Arg,
|
||||
typename std::enable_if_t<
|
||||
typename std::enable_if_t<std::is_integral<Arg>::value &&
|
||||
X86ISA::EmuLinux::SyscallABI32::IsWide<Arg>::value>>
|
||||
{
|
||||
using ABI = X86ISA::EmuLinux::SyscallABI32;
|
||||
|
||||
@@ -36,18 +36,6 @@
|
||||
|
||||
class SyscallDesc;
|
||||
|
||||
namespace GuestABI
|
||||
{
|
||||
|
||||
// Does this normally 64 bit data type shrink down to 32 bits for 32 bit ABIs?
|
||||
template <typename T, typename Enabled=void>
|
||||
struct IsConforming : public std::false_type {};
|
||||
|
||||
template <>
|
||||
struct IsConforming<Addr> : public std::true_type {};
|
||||
|
||||
} // namespace GuestABI
|
||||
|
||||
struct GenericSyscallABI
|
||||
{
|
||||
using State = int;
|
||||
@@ -64,25 +52,12 @@ struct GenericSyscallABI32 : public GenericSyscallABI
|
||||
|
||||
// Is this argument too big for a single register?
|
||||
template <typename T, typename Enabled=void>
|
||||
struct IsWide;
|
||||
struct IsWide : public std::false_type {};
|
||||
|
||||
template <typename T>
|
||||
struct IsWide<T, typename std::enable_if_t<
|
||||
std::is_integral<T>::value &&
|
||||
(sizeof(T) <= sizeof(UintPtr) ||
|
||||
GuestABI::IsConforming<T>::value)>>
|
||||
{
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct IsWide<T, typename std::enable_if_t<
|
||||
std::is_integral<T>::value &&
|
||||
(sizeof(T) > sizeof(UintPtr)) &&
|
||||
!GuestABI::IsConforming<T>::value>>
|
||||
{
|
||||
static const bool value = true;
|
||||
};
|
||||
struct IsWide<T, std::enable_if_t<(sizeof(T) > sizeof(UintPtr))>> :
|
||||
public std::true_type
|
||||
{};
|
||||
|
||||
// Read two registers and merge them into one value.
|
||||
static uint64_t
|
||||
@@ -117,7 +92,8 @@ struct Argument<ABI, Arg,
|
||||
// arguments aren't handled generically.
|
||||
template <typename ABI, typename Arg>
|
||||
struct Argument<ABI, Arg,
|
||||
typename std::enable_if_t<!ABI::template IsWide<Arg>::value>>
|
||||
typename std::enable_if_t<std::is_integral<Arg>::value &&
|
||||
!ABI::template IsWide<Arg>::value>>
|
||||
{
|
||||
static Arg
|
||||
get(ThreadContext *tc, typename ABI::State &state)
|
||||
|
||||
Reference in New Issue
Block a user