From b3b81196aad0a8acbeea59d274b9afbe083c1b1a Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Mon, 26 Jul 2021 17:03:30 -0700 Subject: [PATCH] misc: Replace type_traits.hh XX::value with XX_v. Now that we're using c++17, the type_traits with a ::value member have a _v alias which reduces verbosity. Or on other words std::is_integral::value can be replaced with std::is_integral_v Make this substitution throughout the code base. In places where gem5 introduced it's own similar templates, add a V alias, spelled differently to match gem5's internal style. gem5: :IsVarArgs::value => gem5::IsVarArgsV Change-Id: I1d84ffc4a236ad699471569e7916ec17fe5f109a Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/48604 Reviewed-by: Daniel Carvalho Maintainer: Bobby R. Bruce Tested-by: kokoro --- src/arch/amdgpu/gcn3/gpu_isa.hh | 2 +- src/arch/amdgpu/gcn3/insts/inst_util.hh | 2 +- src/arch/amdgpu/gcn3/operand.hh | 8 +- src/arch/amdgpu/vega/gpu_isa.hh | 4 +- src/arch/amdgpu/vega/insts/inst_util.hh | 2 +- src/arch/amdgpu/vega/operand.hh | 8 +- src/arch/arm/aapcs32.hh | 58 ++++++------ src/arch/arm/aapcs64.hh | 54 +++++++----- src/arch/arm/aapcs64.test.cc | 88 +++++++++---------- src/arch/arm/freebsd/se_workload.hh | 4 +- src/arch/arm/linux/se_workload.hh | 4 +- src/arch/arm/reg_abi.hh | 6 +- src/arch/arm/semihosting.hh | 8 +- src/arch/sparc/se_workload.hh | 8 +- src/arch/x86/bios/acpi.hh | 20 ++--- src/arch/x86/linux/linux.hh | 3 +- src/arch/x86/linux/se_workload.hh | 4 +- src/base/bitunion.hh | 3 +- src/base/bitunion.test.cc | 4 +- src/base/circular_queue.hh | 8 +- src/base/coroutine.hh | 17 ++-- src/base/flags.hh | 2 +- src/base/intmath.hh | 2 +- src/base/random.hh | 6 +- src/base/refcnt.hh | 2 +- src/base/statistics.hh | 4 +- src/base/stats/units.hh | 8 +- src/base/stl_helpers.hh | 5 +- src/base/str.hh | 12 +-- src/base/trie.hh | 3 +- src/cpu/inst_res.hh | 7 +- src/dev/reg_bank.hh | 8 +- src/dev/virtio/base.hh | 4 +- .../compressors/dictionary_compressor.hh | 2 +- src/mem/cache/prefetch/associative_set.hh | 2 +- src/mem/cache/queue.hh | 2 +- src/python/m5/SimObject.py | 8 +- src/sim/byteswap.hh | 12 +-- src/sim/guest_abi.test.cc | 18 ++-- src/sim/guest_abi/layout.hh | 7 +- src/sim/guest_abi/varargs.hh | 3 + src/sim/proxy_ptr.hh | 34 +++---- src/sim/proxy_ptr.test.cc | 8 +- src/sim/serialize_handlers.hh | 8 +- src/sim/syscall_abi.hh | 11 ++- 45 files changed, 256 insertions(+), 237 deletions(-) diff --git a/src/arch/amdgpu/gcn3/gpu_isa.hh b/src/arch/amdgpu/gcn3/gpu_isa.hh index 076e2a6576..65136bb3ad 100644 --- a/src/arch/amdgpu/gcn3/gpu_isa.hh +++ b/src/arch/amdgpu/gcn3/gpu_isa.hh @@ -57,7 +57,7 @@ namespace Gcn3ISA template T readConstVal(int opIdx) const { - panic_if(!std::is_integral::value, "Constant values must " + panic_if(!std::is_integral_v, "Constant values must " "be an integer.\n"); T val(0); diff --git a/src/arch/amdgpu/gcn3/insts/inst_util.hh b/src/arch/amdgpu/gcn3/insts/inst_util.hh index 95cb6dbb3f..dddbce476e 100644 --- a/src/arch/amdgpu/gcn3/insts/inst_util.hh +++ b/src/arch/amdgpu/gcn3/insts/inst_util.hh @@ -247,7 +247,7 @@ namespace Gcn3ISA inline T median(T val_0, T val_1, T val_2) { - if (std::is_floating_point::value) { + if (std::is_floating_point_v) { return std::fmax(std::fmin(val_0, val_1), std::fmin(std::fmax(val_0, val_1), val_2)); } else { diff --git a/src/arch/amdgpu/gcn3/operand.hh b/src/arch/amdgpu/gcn3/operand.hh index 12f5d27a07..e8e93215be 100644 --- a/src/arch/amdgpu/gcn3/operand.hh +++ b/src/arch/amdgpu/gcn3/operand.hh @@ -274,12 +274,12 @@ namespace Gcn3ISA DataType ret_val = scRegData.rawData(); if (absMod) { - assert(std::is_floating_point::value); + assert(std::is_floating_point_v); ret_val = std::fabs(ret_val); } if (negMod) { - assert(std::is_floating_point::value); + assert(std::is_floating_point_v); ret_val = -ret_val; } @@ -289,12 +289,12 @@ namespace Gcn3ISA DataType ret_val = vgpr[idx]; if (absMod) { - assert(std::is_floating_point::value); + assert(std::is_floating_point_v); ret_val = std::fabs(ret_val); } if (negMod) { - assert(std::is_floating_point::value); + assert(std::is_floating_point_v); ret_val = -ret_val; } diff --git a/src/arch/amdgpu/vega/gpu_isa.hh b/src/arch/amdgpu/vega/gpu_isa.hh index c962398004..925503fa1f 100644 --- a/src/arch/amdgpu/vega/gpu_isa.hh +++ b/src/arch/amdgpu/vega/gpu_isa.hh @@ -57,8 +57,8 @@ namespace VegaISA template T readConstVal(int opIdx) const { - panic_if(!std::is_integral::value, "Constant values must " - "be an integer.\n"); + panic_if(!std::is_integral_v, + "Constant values must be an integer."); T val(0); if (isPosConstVal(opIdx)) { diff --git a/src/arch/amdgpu/vega/insts/inst_util.hh b/src/arch/amdgpu/vega/insts/inst_util.hh index d392ac84d9..55176e5b61 100644 --- a/src/arch/amdgpu/vega/insts/inst_util.hh +++ b/src/arch/amdgpu/vega/insts/inst_util.hh @@ -247,7 +247,7 @@ namespace VegaISA inline T median(T val_0, T val_1, T val_2) { - if (std::is_floating_point::value) { + if (std::is_floating_point_v) { return std::fmax(std::fmin(val_0, val_1), std::fmin(std::fmax(val_0, val_1), val_2)); } else { diff --git a/src/arch/amdgpu/vega/operand.hh b/src/arch/amdgpu/vega/operand.hh index aa8b8545d5..1c37a0f76f 100644 --- a/src/arch/amdgpu/vega/operand.hh +++ b/src/arch/amdgpu/vega/operand.hh @@ -274,12 +274,12 @@ namespace VegaISA DataType ret_val = scRegData.rawData(); if (absMod) { - assert(std::is_floating_point::value); + assert(std::is_floating_point_v); ret_val = std::fabs(ret_val); } if (negMod) { - assert(std::is_floating_point::value); + assert(std::is_floating_point_v); ret_val = -ret_val; } @@ -289,12 +289,12 @@ namespace VegaISA DataType ret_val = vgpr[idx]; if (absMod) { - assert(std::is_floating_point::value); + assert(std::is_floating_point_v); ret_val = std::fabs(ret_val); } if (negMod) { - assert(std::is_floating_point::value); + assert(std::is_floating_point_v); ret_val = -ret_val; } diff --git a/src/arch/arm/aapcs32.hh b/src/arch/arm/aapcs32.hh index 84bd5d641e..75c8593977 100644 --- a/src/arch/arm/aapcs32.hh +++ b/src/arch/arm/aapcs32.hh @@ -82,14 +82,15 @@ struct IsAapcs32Composite : public std::false_type {}; template struct IsAapcs32Composite::value || - std::is_class::value || - std::is_union::value) && + (std::is_array_v || std::is_class_v || std::is_union_v) && // VarArgs is technically a composite type, but it's not a normal argument. - !IsVarArgs::value + !IsVarArgsV >> : public std::true_type {}; +template +constexpr bool IsAapcs32CompositeV = IsAapcs32Composite::value; + // Homogeneous Aggregates // These *should* be any aggregate type which has only one type of member, but // we can't actually detect that or manipulate that with templates. Instead, @@ -104,6 +105,10 @@ struct IsAapcs32HomogeneousAggregate : public std::false_type {}; template struct IsAapcs32HomogeneousAggregate : public std::true_type {}; +template +constexpr bool IsAapcs32HomogeneousAggregateV = + IsAapcs32HomogeneousAggregate::value; + struct Aapcs32ArgumentBase { template @@ -138,12 +143,12 @@ struct Aapcs32ArgumentBase template struct Result::value && (sizeof(Integer) < sizeof(uint32_t))>> + std::is_integral_v && (sizeof(Integer) < sizeof(uint32_t))>> { static void store(ThreadContext *tc, const Integer &i) { - uint32_t val = std::is_signed::value ? + uint32_t val = std::is_signed_v ? sext(i) : i; tc->setIntReg(ArmISA::INTREG_R0, val); } @@ -151,7 +156,7 @@ struct Result struct Result::value && (sizeof(Integer) == sizeof(uint32_t))>> + std::is_integral_v && (sizeof(Integer) == sizeof(uint32_t))>> { static void store(ThreadContext *tc, const Integer &i) @@ -162,7 +167,7 @@ struct Result struct Result::value && (sizeof(Integer) == sizeof(uint64_t))>> + std::is_integral_v && (sizeof(Integer) == sizeof(uint64_t))>> { static void store(ThreadContext *tc, const Integer &i) @@ -179,7 +184,7 @@ struct Result struct Argument::value && (sizeof(Integer) <= sizeof(uint32_t)) + std::is_integral_v && (sizeof(Integer) <= sizeof(uint32_t)) >> : public Aapcs32ArgumentBase { static Integer @@ -198,7 +203,7 @@ struct Argument struct Argument::value && (sizeof(Integer) > sizeof(uint32_t)) + std::is_integral_v && (sizeof(Integer) > sizeof(uint32_t)) >> : public Aapcs32ArgumentBase { static Integer @@ -234,7 +239,7 @@ struct Argument struct Result::value>> + std::is_floating_point_v>> { static void store(ThreadContext *tc, const Float &f, Aapcs32::State &state) @@ -246,7 +251,7 @@ struct Result struct Argument::value>> : public Aapcs32ArgumentBase + std::is_floating_point_v>> : public Aapcs32ArgumentBase { static Float get(ThreadContext *tc, Aapcs32::State &state) @@ -268,7 +273,7 @@ struct Argument struct Result::value>> + IsAapcs32CompositeV>> { static void store(ThreadContext *tc, const Composite &composite, @@ -296,7 +301,7 @@ struct Result struct Argument::value>> : + IsAapcs32CompositeV>> : public Aapcs32ArgumentBase { static Composite @@ -445,13 +450,12 @@ namespace guest_abi template struct Result::value>> : public Result + std::is_integral_v>> : public Result {}; template struct Argument::value>> : - public Argument + std::is_integral_v>> : public Argument {}; @@ -461,7 +465,7 @@ struct Argument struct Result::value>> + std::is_floating_point_v>> { static void store(ThreadContext *tc, const Float &f, Aapcs32Vfp::State &state) @@ -480,7 +484,7 @@ struct Result struct Argument::value>> : public Aapcs32ArgumentBase + std::is_floating_point_v>> : public Aapcs32ArgumentBase { static Float get(ThreadContext *tc, Aapcs32Vfp::State &state) @@ -511,15 +515,15 @@ struct Argument struct Result::value && - !IsAapcs32HomogeneousAggregate::value>> : + IsAapcs32CompositeV && + !IsAapcs32HomogeneousAggregateV>> : public Result {}; template struct Argument::value && - !IsAapcs32HomogeneousAggregate::value>> : + IsAapcs32CompositeV && + !IsAapcs32HomogeneousAggregateV>> : public Argument {}; @@ -536,7 +540,7 @@ struct Aapcs32ArrayType { using Type = E; }; template struct Argument::value>> : + IsAapcs32HomogeneousAggregateV>> : public Aapcs32ArgumentBase { static bool @@ -544,7 +548,7 @@ struct Argument::Type; constexpr size_t Count = sizeof(HA) / sizeof(Elem); - return state.variadic || !std::is_floating_point::value || + return state.variadic || !std::is_floating_point_v || Count > 4; } @@ -586,14 +590,14 @@ struct Argument struct Result::value>> + typename std::enable_if_t>> { static bool useBaseABI(Aapcs32Vfp::State &state) { using Elem = typename Aapcs32ArrayType::Type; constexpr size_t Count = sizeof(HA) / sizeof(Elem); - return state.variadic || !std::is_floating_point::value || + return state.variadic || !std::is_floating_point_v || Count > 4; } diff --git a/src/arch/arm/aapcs64.hh b/src/arch/arm/aapcs64.hh index dd5a62e614..7f2d1628b8 100644 --- a/src/arch/arm/aapcs64.hh +++ b/src/arch/arm/aapcs64.hh @@ -84,11 +84,14 @@ struct IsAapcs64ShortVector : public std::false_type {}; template struct IsAapcs64ShortVector::value || std::is_floating_point::value) && + (std::is_integral_v || std::is_floating_point_v) && (sizeof(E) * N == 8 || sizeof(E) * N == 16)>> : public std::true_type {}; +template +constexpr bool IsAapcs64ShortVectorV = IsAapcs64ShortVector::value; + /* * Composite Types */ @@ -98,16 +101,17 @@ struct IsAapcs64Composite : public std::false_type {}; template struct IsAapcs64Composite::value || - std::is_class::value || - std::is_union::value) && + (std::is_array_v || std::is_class_v || std::is_union_v) && // VarArgs is technically a composite type, but it's not a normal argument. - !IsVarArgs::value && + !IsVarArgsV && // Short vectors are also composite types, but don't treat them as one. - !IsAapcs64ShortVector::value + !IsAapcs64ShortVectorV >> : public std::true_type {}; +template +constexpr bool IsAapcs64CompositeV = IsAapcs64Composite::value; + // Homogeneous Aggregates // These *should* be any aggregate type which has only one type of member, but // we can't actually detect that or manipulate that with templates. Instead, @@ -122,10 +126,13 @@ struct IsAapcs64Hfa : public std::false_type {}; template struct IsAapcs64Hfa::value && N <= 4>> : + typename std::enable_if_t && N <= 4>> : public std::true_type {}; +template +constexpr bool IsAapcs64HfaV = IsAapcs64Hfa::value; + // An Homogeneous Short-Vector Aggregate (HVA) is an Homogeneous Aggregate with // a Fundamental Data Type that is a Short-Vector type and at most four // uniquely addressable members. @@ -135,20 +142,26 @@ struct IsAapcs64Hva : public std::false_type {}; template struct IsAapcs64Hva::value && N <= 4>> : + typename std::enable_if_t && N <= 4>> : public std::true_type {}; +template +constexpr bool IsAapcs64HvaV = IsAapcs64Hva::value; + // A shorthand to test if a type is an HVA or an HFA. template struct IsAapcs64Hxa : public std::false_type {}; template struct IsAapcs64Hxa::value || IsAapcs64Hva::value>> : + IsAapcs64HfaV || IsAapcs64HvaV>> : public std::true_type {}; +template +constexpr bool IsAapcs64HxaV = IsAapcs64Hxa::value; + struct Aapcs64ArgumentBase { template @@ -181,8 +194,7 @@ struct Aapcs64ArgumentBase template struct Argument::value || - IsAapcs64ShortVector::value>> : + std::is_floating_point_v || IsAapcs64ShortVectorV>> : public Aapcs64ArgumentBase { static Float @@ -199,8 +211,7 @@ struct Argument struct Result::value || - IsAapcs64ShortVector::value>> + std::is_floating_point_v || IsAapcs64ShortVectorV>> { static void store(ThreadContext *tc, const Float &f) @@ -220,7 +231,7 @@ struct Result struct Argument::value && (sizeof(Integer) <= 8)>> : + std::is_integral_v && (sizeof(Integer) <= 8)>> : public Aapcs64ArgumentBase { static Integer @@ -238,7 +249,7 @@ struct Argument struct Argument::value && (sizeof(Integer) > 8)>> : + std::is_integral_v && (sizeof(Integer) > 8)>> : public Aapcs64ArgumentBase { static Integer @@ -263,7 +274,7 @@ struct Argument struct Result::value && (sizeof(Integer) <= 8)>> + std::is_integral_v && (sizeof(Integer) <= 8)>> { static void store(ThreadContext *tc, const Integer &i) @@ -274,7 +285,7 @@ struct Result struct Result::value && (sizeof(Integer) > 8)>> + std::is_integral_v && (sizeof(Integer) > 8)>> { static void store(ThreadContext *tc, const Integer &i) @@ -298,7 +309,7 @@ struct Aapcs64ArrayType { using Type = E; }; template struct Argument::value>> : public Aapcs64ArgumentBase + IsAapcs64HxaV>> : public Aapcs64ArgumentBase { static HA get(ThreadContext *tc, Aapcs64::State &state) @@ -321,8 +332,7 @@ struct Argument -struct Result::value>> +struct Result>> { static HA store(ThreadContext *tc, const HA &ha) @@ -342,7 +352,7 @@ struct Result struct Argument::value && !IsAapcs64Hxa::value>> : + IsAapcs64CompositeV && !IsAapcs64HxaV>> : public Aapcs64ArgumentBase { static Composite @@ -387,7 +397,7 @@ struct Argument struct Result::value && !IsAapcs64Hxa::value>> + IsAapcs64CompositeV && !IsAapcs64HxaV>> { static void store(ThreadContext *tc, const Composite &c) diff --git a/src/arch/arm/aapcs64.test.cc b/src/arch/arm/aapcs64.test.cc index 5d96ff6c4a..6b5ba4d3e0 100644 --- a/src/arch/arm/aapcs64.test.cc +++ b/src/arch/arm/aapcs64.test.cc @@ -42,41 +42,41 @@ TEST(Aapcs64, IsAapcs64ShortVector) using EightLongFloat = float[2]; using SixteenLongFloat = double[2]; - EXPECT_FALSE(guest_abi::IsAapcs64ShortVector::value); - EXPECT_FALSE(guest_abi::IsAapcs64ShortVector::value); - EXPECT_FALSE(guest_abi::IsAapcs64ShortVector::value); - EXPECT_FALSE(guest_abi::IsAapcs64ShortVector::value); - EXPECT_FALSE(guest_abi::IsAapcs64ShortVector::value); + EXPECT_FALSE(guest_abi::IsAapcs64ShortVectorV); + EXPECT_FALSE(guest_abi::IsAapcs64ShortVectorV); + EXPECT_FALSE(guest_abi::IsAapcs64ShortVectorV); + EXPECT_FALSE(guest_abi::IsAapcs64ShortVectorV); + EXPECT_FALSE(guest_abi::IsAapcs64ShortVectorV); - EXPECT_TRUE(guest_abi::IsAapcs64ShortVector::value); - EXPECT_TRUE(guest_abi::IsAapcs64ShortVector::value); - EXPECT_TRUE(guest_abi::IsAapcs64ShortVector::value); - EXPECT_TRUE(guest_abi::IsAapcs64ShortVector::value); + EXPECT_TRUE(guest_abi::IsAapcs64ShortVectorV); + EXPECT_TRUE(guest_abi::IsAapcs64ShortVectorV); + EXPECT_TRUE(guest_abi::IsAapcs64ShortVectorV); + EXPECT_TRUE(guest_abi::IsAapcs64ShortVectorV); } TEST(Aapcs64, IsAapcs64Hfa) { // Accept floating point arrays with up to 4 members. - EXPECT_TRUE(guest_abi::IsAapcs64Hfa::value); - EXPECT_TRUE(guest_abi::IsAapcs64Hfa::value); - EXPECT_TRUE(guest_abi::IsAapcs64Hfa::value); - EXPECT_TRUE(guest_abi::IsAapcs64Hfa::value); + EXPECT_TRUE(guest_abi::IsAapcs64HfaV); + EXPECT_TRUE(guest_abi::IsAapcs64HfaV); + EXPECT_TRUE(guest_abi::IsAapcs64HfaV); + EXPECT_TRUE(guest_abi::IsAapcs64HfaV); - EXPECT_TRUE(guest_abi::IsAapcs64Hfa::value); - EXPECT_TRUE(guest_abi::IsAapcs64Hfa::value); - EXPECT_TRUE(guest_abi::IsAapcs64Hfa::value); - EXPECT_TRUE(guest_abi::IsAapcs64Hfa::value); + EXPECT_TRUE(guest_abi::IsAapcs64HfaV); + EXPECT_TRUE(guest_abi::IsAapcs64HfaV); + EXPECT_TRUE(guest_abi::IsAapcs64HfaV); + EXPECT_TRUE(guest_abi::IsAapcs64HfaV); // Too many members. - EXPECT_FALSE(guest_abi::IsAapcs64Hfa::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hfa::value); + EXPECT_FALSE(guest_abi::IsAapcs64HfaV); + EXPECT_FALSE(guest_abi::IsAapcs64HfaV); // Wrong type of members, or not arrays. - EXPECT_FALSE(guest_abi::IsAapcs64Hfa::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hfa::value); + EXPECT_FALSE(guest_abi::IsAapcs64HfaV); + EXPECT_FALSE(guest_abi::IsAapcs64HfaV); struct Struct {}; - EXPECT_FALSE(guest_abi::IsAapcs64Hfa::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hfa::value); + EXPECT_FALSE(guest_abi::IsAapcs64HfaV); + EXPECT_FALSE(guest_abi::IsAapcs64HfaV); } TEST(Aapcs64, IsAapcs64Hva) @@ -85,36 +85,36 @@ TEST(Aapcs64, IsAapcs64Hva) using SvaTiny = uint8_t[16]; using SvaFloat = float[2]; - EXPECT_TRUE(guest_abi::IsAapcs64Hva::value); - EXPECT_TRUE(guest_abi::IsAapcs64Hva::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hva::value); + EXPECT_TRUE(guest_abi::IsAapcs64HvaV); + EXPECT_TRUE(guest_abi::IsAapcs64HvaV); + EXPECT_FALSE(guest_abi::IsAapcs64HvaV); - EXPECT_TRUE(guest_abi::IsAapcs64Hva::value); - EXPECT_TRUE(guest_abi::IsAapcs64Hva::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hva::value); + EXPECT_TRUE(guest_abi::IsAapcs64HvaV); + EXPECT_TRUE(guest_abi::IsAapcs64HvaV); + EXPECT_FALSE(guest_abi::IsAapcs64HvaV); - EXPECT_TRUE(guest_abi::IsAapcs64Hva::value); - EXPECT_TRUE(guest_abi::IsAapcs64Hva::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hva::value); + EXPECT_TRUE(guest_abi::IsAapcs64HvaV); + EXPECT_TRUE(guest_abi::IsAapcs64HvaV); + EXPECT_FALSE(guest_abi::IsAapcs64HvaV); - EXPECT_FALSE(guest_abi::IsAapcs64Hva::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hva::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hva::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hva::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hva::value); + EXPECT_FALSE(guest_abi::IsAapcs64HvaV); + EXPECT_FALSE(guest_abi::IsAapcs64HvaV); + EXPECT_FALSE(guest_abi::IsAapcs64HvaV); + EXPECT_FALSE(guest_abi::IsAapcs64HvaV); + EXPECT_FALSE(guest_abi::IsAapcs64HvaV); } TEST(Aapcs64, IsAapcs64Hxa) { using SvaInt = uint32_t[2]; - EXPECT_TRUE(guest_abi::IsAapcs64Hxa::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hxa::value); + EXPECT_TRUE(guest_abi::IsAapcs64HxaV); + EXPECT_FALSE(guest_abi::IsAapcs64HxaV); - EXPECT_TRUE(guest_abi::IsAapcs64Hxa::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hxa::value); + EXPECT_TRUE(guest_abi::IsAapcs64HxaV); + EXPECT_FALSE(guest_abi::IsAapcs64HxaV); - EXPECT_FALSE(guest_abi::IsAapcs64Hxa::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hxa::value); - EXPECT_FALSE(guest_abi::IsAapcs64Hxa::value); + EXPECT_FALSE(guest_abi::IsAapcs64HxaV); + EXPECT_FALSE(guest_abi::IsAapcs64HxaV); + EXPECT_FALSE(guest_abi::IsAapcs64HxaV); } diff --git a/src/arch/arm/freebsd/se_workload.hh b/src/arch/arm/freebsd/se_workload.hh index a96dcf2b5e..0d04284b69 100644 --- a/src/arch/arm/freebsd/se_workload.hh +++ b/src/arch/arm/freebsd/se_workload.hh @@ -73,8 +73,8 @@ namespace guest_abi template struct Result::value>> + typename std::enable_if_t>> { static void store(ThreadContext *tc, const SyscallReturn &ret) diff --git a/src/arch/arm/linux/se_workload.hh b/src/arch/arm/linux/se_workload.hh index 0f9b9b90a0..f7f469ce73 100644 --- a/src/arch/arm/linux/se_workload.hh +++ b/src/arch/arm/linux/se_workload.hh @@ -66,8 +66,8 @@ namespace guest_abi template struct Result::value>> + typename std::enable_if_t>> { static void store(ThreadContext *tc, const SyscallReturn &ret) diff --git a/src/arch/arm/reg_abi.hh b/src/arch/arm/reg_abi.hh index c8f3effd66..d8a0ffae8a 100644 --- a/src/arch/arm/reg_abi.hh +++ b/src/arch/arm/reg_abi.hh @@ -58,9 +58,9 @@ namespace guest_abi template struct Argument::value && - std::is_integral::value && - ABI::template IsWide::value>> + std::is_base_of_v && + std::is_integral_v && + ABI::template IsWideV>> { static Arg get(ThreadContext *tc, typename ABI::State &state) diff --git a/src/arch/arm/semihosting.hh b/src/arch/arm/semihosting.hh index a21852d3df..a9bdbadb74 100644 --- a/src/arch/arm/semihosting.hh +++ b/src/arch/arm/semihosting.hh @@ -605,7 +605,7 @@ namespace guest_abi template struct Argument::value>> + typename std::enable_if_t>> { static Arg get(ThreadContext *tc, ArmSemihosting::Abi64::State &state) @@ -616,12 +616,12 @@ struct Argument struct Argument::value>> + typename std::enable_if_t>> { static Arg get(ThreadContext *tc, ArmSemihosting::Abi32::State &state) { - if (std::is_signed::value) + if (std::is_signed_v) return sext<32>(state.get(tc)); else return state.get(tc); @@ -630,7 +630,7 @@ struct Argument struct Argument::value>> + std::is_base_of_v>> { static ArmSemihosting::InPlaceArg get(ThreadContext *tc, typename Abi::State &state) diff --git a/src/arch/sparc/se_workload.hh b/src/arch/sparc/se_workload.hh index f821aef529..6d034f7ced 100644 --- a/src/arch/sparc/se_workload.hh +++ b/src/arch/sparc/se_workload.hh @@ -83,8 +83,8 @@ namespace guest_abi template struct Result::value>> + typename std::enable_if_t>> { static void store(ThreadContext *tc, const SyscallReturn &ret) @@ -118,8 +118,8 @@ struct Result struct Argument::value && - SparcISA::SEWorkload::SyscallABI32::IsWide::value>> + std::is_integral_v && + SparcISA::SEWorkload::SyscallABI32::IsWideV>> { using ABI = SparcISA::SEWorkload::SyscallABI32; diff --git a/src/arch/x86/bios/acpi.hh b/src/arch/x86/bios/acpi.hh index f6d94eec24..bbad0f8a75 100644 --- a/src/arch/x86/bios/acpi.hh +++ b/src/arch/x86/bios/acpi.hh @@ -107,7 +107,7 @@ class RSDP : public SimObject uint8_t revision = 0; uint32_t rsdtAddress = 0; }; - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "Type not suitable for memcpy."); struct GEM5_PACKED Mem : public MemR0 @@ -118,7 +118,7 @@ class RSDP : public SimObject uint8_t extendedChecksum = 0; uint8_t _reserved[3] = {}; }; - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "Type not suitable for memcpy,"); RSDT* rsdt; @@ -148,7 +148,7 @@ class SysDescTable : public SimObject uint32_t creatorID = 0; uint32_t creatorRevision = 0; }; - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "Type not suitable for memcpy."); virtual Addr writeBuf(PortProxy& phys_proxy, Allocator& alloc, @@ -215,7 +215,7 @@ class Record : public SimObject uint8_t type = 0; uint8_t length = 0; }; - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "Type not suitable for memcpy."); uint8_t type; @@ -245,7 +245,7 @@ class LAPIC : public Record uint8_t apicId = 0; uint32_t flags = 0; }; - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "Type not suitable for memcpy."); void prepareBuf(std::vector& mem) const override; @@ -266,7 +266,7 @@ class IOAPIC : public Record uint32_t ioApicAddress = 0; uint32_t intBase = 0; }; - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "Type not suitable for memcpy."); void prepareBuf(std::vector& mem) const override; @@ -287,7 +287,7 @@ class IntSourceOverride : public Record uint32_t globalSystemInterrupt = 0; uint16_t flags = 0; }; - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "Type not suitable for memcpy."); void prepareBuf(std::vector& mem) const override; @@ -307,7 +307,7 @@ class NMI : public Record uint16_t flags = 0; uint8_t lintNo = 0; }; - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "Type not suitable for memcpy."); void prepareBuf(std::vector& mem) const override; @@ -326,7 +326,7 @@ class LAPICOverride : public Record uint16_t _reserved = 0; uint64_t localAPICAddress = 0; }; - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "Type not suitable for memcpy."); void prepareBuf(std::vector& mem) const override; @@ -345,7 +345,7 @@ class MADT : public SysDescTable uint32_t localAPICAddress = 0; uint32_t flags = 0; }; - static_assert(std::is_trivially_copyable::value, + static_assert(std::is_trivially_copyable_v, "Type not suitable for memcpy."); std::vector records; diff --git a/src/arch/x86/linux/linux.hh b/src/arch/x86/linux/linux.hh index 957d3483e4..cbf73580f4 100644 --- a/src/arch/x86/linux/linux.hh +++ b/src/arch/x86/linux/linux.hh @@ -81,8 +81,7 @@ namespace guest_abi template struct Result::value>> + typename std::enable_if_t>> { static void store(ThreadContext *tc, const SyscallReturn &ret) diff --git a/src/arch/x86/linux/se_workload.hh b/src/arch/x86/linux/se_workload.hh index 02a4dc2f75..76db91f42d 100644 --- a/src/arch/x86/linux/se_workload.hh +++ b/src/arch/x86/linux/se_workload.hh @@ -99,8 +99,8 @@ namespace guest_abi template struct Argument::value && - X86ISA::EmuLinux::SyscallABI32::IsWide::value>> + typename std::enable_if_t && + X86ISA::EmuLinux::SyscallABI32::IsWideV>> { using ABI = X86ISA::EmuLinux::SyscallABI32; diff --git a/src/base/bitunion.hh b/src/base/bitunion.hh index d062443014..92d747cd1a 100644 --- a/src/base/bitunion.hh +++ b/src/base/bitunion.hh @@ -56,8 +56,7 @@ namespace gem5 template class BitfieldTypeImpl : public Base { - static_assert(std::is_empty::value, - "Bitfield base class must be empty."); + static_assert(std::is_empty_v, "Bitfield base class must be empty."); private: diff --git a/src/base/bitunion.test.cc b/src/base/bitunion.test.cc index ee12be7f99..7300efe2ae 100644 --- a/src/base/bitunion.test.cc +++ b/src/base/bitunion.test.cc @@ -264,9 +264,9 @@ TEST_F(BitUnionData, Templating) EndBitUnion(Dummy32); bool is64; - is64 = std::is_same, uint64_t>::value; + is64 = std::is_same_v, uint64_t>; EXPECT_TRUE(is64); - is64 = std::is_same, uint64_t>::value; + is64 = std::is_same_v, uint64_t>; EXPECT_FALSE(is64); } diff --git a/src/base/circular_queue.hh b/src/base/circular_queue.hh index 859d12ef7b..63d60a55f5 100644 --- a/src/base/circular_queue.hh +++ b/src/base/circular_queue.hh @@ -112,7 +112,7 @@ class CircularQueue /** Trait reference type * iterator satisfies OutputIterator, therefore reference * must be T& */ - static_assert(std::is_same::value, + static_assert(std::is_same_v, "reference type is not assignable as required"); /** @@ -348,7 +348,7 @@ class CircularQueue * @ingroup api_base_utils */ template - typename std::enable_if_t::value, reference> + typename std::enable_if_t, reference> operator[](const Idx& index) { return *(*this + index); @@ -391,7 +391,7 @@ class CircularQueue * @ingroup api_base_utils */ template - typename std::enable_if_t::value, reference> + typename std::enable_if_t, reference> operator[](const Idx& index) { assert(index >= 0); @@ -399,7 +399,7 @@ class CircularQueue } template - typename std::enable_if_t::value, const_reference> + typename std::enable_if_t, const_reference> operator[](const Idx& index) const { assert(index >= 0); diff --git a/src/base/coroutine.hh b/src/base/coroutine.hh index dbdddc24e0..63b26aa3eb 100644 --- a/src/base/coroutine.hh +++ b/src/base/coroutine.hh @@ -69,10 +69,10 @@ class Coroutine : public Fiber // are void. (See following ArgChannel, RetChannel typedef) struct Empty {}; using ArgChannel = typename std::conditional_t< - std::is_same::value, Empty, std::stack>; + std::is_same_v, Empty, std::stack>; using RetChannel = typename std::conditional_t< - std::is_same::value, Empty, std::stack>; + std::is_same_v, Empty, std::stack>; public: /** @@ -101,7 +101,7 @@ class Coroutine : public Fiber template CallerType& operator()(typename std::enable_if_t< - !std::is_same::value, T> param) + !std::is_same_v, T> param) { retChannel.push(param); callerFiber->run(); @@ -117,7 +117,7 @@ class Coroutine : public Fiber * @ingroup api_coroutine */ template - typename std::enable_if_t::value, + typename std::enable_if_t, CallerType> & operator()() { @@ -138,7 +138,7 @@ class Coroutine : public Fiber * @ingroup api_coroutine */ template - typename std::enable_if_t::value, T> + typename std::enable_if_t, T> get() { auto& args_channel = coro.argsChannel; @@ -210,8 +210,7 @@ class Coroutine : public Fiber */ template Coroutine& - operator()(typename std::enable_if_t< - !std::is_same::value, T> param) + operator()(typename std::enable_if_t, T> param) { argsChannel.push(param); this->call(); @@ -227,7 +226,7 @@ class Coroutine : public Fiber * @ingroup api_coroutine */ template - typename std::enable_if_t::value, Coroutine> & + typename std::enable_if_t, Coroutine> & operator()() { this->call(); @@ -247,7 +246,7 @@ class Coroutine : public Fiber * @ingroup api_coroutine */ template - typename std::enable_if_t::value, T> + typename std::enable_if_t, T> get() { auto& ret_channel = caller.retChannel; diff --git a/src/base/flags.hh b/src/base/flags.hh index 4f7a52eca0..4ea8f4841a 100644 --- a/src/base/flags.hh +++ b/src/base/flags.hh @@ -44,7 +44,7 @@ template class Flags { private: - static_assert(std::is_unsigned::value, "Flag type must be unsigned"); + static_assert(std::is_unsigned_v, "Flag type must be unsigned"); /** The undelying container of the flags' bits. */ T _flags; diff --git a/src/base/intmath.hh b/src/base/intmath.hh index 5ce5b5bb0e..566fe2dd46 100644 --- a/src/base/intmath.hh +++ b/src/base/intmath.hh @@ -55,7 +55,7 @@ namespace gem5 * @ingroup api_base_utils */ template -static constexpr std::enable_if_t::value, int> +static constexpr std::enable_if_t, int> floorLog2(T x) { assert(x > 0); diff --git a/src/base/random.hh b/src/base/random.hh index 55d72451d3..5e6cf23f90 100644 --- a/src/base/random.hh +++ b/src/base/random.hh @@ -86,7 +86,7 @@ class Random : public Serializable * @ingroup api_base_utils */ template - typename std::enable_if_t::value, T> + typename std::enable_if_t, T> random() { // [0, max_value] for integer types @@ -98,7 +98,7 @@ class Random : public Serializable * @ingroup api_base_utils */ template - typename std::enable_if_t::value, T> + typename std::enable_if_t, T> random() { // [0, 1) for real types @@ -109,7 +109,7 @@ class Random : public Serializable * @ingroup api_base_utils */ template - typename std::enable_if_t::value, T> + typename std::enable_if_t, T> random(T min, T max) { std::uniform_int_distribution dist(min, max); diff --git a/src/base/refcnt.hh b/src/base/refcnt.hh index b9546d3b1a..d0f156e516 100644 --- a/src/base/refcnt.hh +++ b/src/base/refcnt.hh @@ -131,7 +131,7 @@ class RefCountingPtr protected: /** Convenience aliases for const/non-const versions of T w/ friendship. */ /** @{ */ - static constexpr auto TisConst = std::is_const::value; + static constexpr auto TisConst = std::is_const_v; using ConstT = typename std::conditional_t, RefCountingPtr::type>>; diff --git a/src/base/statistics.hh b/src/base/statistics.hh index 18f52cb580..7714ce4c78 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -675,8 +675,8 @@ class FunctorProxy : public ProxyInfo */ template class FunctorProxy, - const T &>::value>> : public ProxyInfo + typename std::enable_if_t, + const T &>>> : public ProxyInfo { private: std::function functor; diff --git a/src/base/stats/units.hh b/src/base/stats/units.hh index 42ebb563dd..52e2e57ce8 100644 --- a/src/base/stats/units.hh +++ b/src/base/stats/units.hh @@ -342,12 +342,12 @@ class Unspecified : public Base template class Rate : public Base { - static_assert(std::is_base_of::value, "Rate(T1,T2) must have " + static_assert(std::is_base_of_v, "Rate(T1,T2) must have " "T1 and T2 derived from statistics::units::Base"); - static_assert(std::is_base_of::value, "Rate(T1,T2) must have " + static_assert(std::is_base_of_v, "Rate(T1,T2) must have " "T1 and T2 derived from statistics::units::Base"); - static_assert(!std::is_same::value || - std::is_same::value || std::is_same::value, + static_assert(!std::is_same_v || std::is_same_v || + std::is_same_v, "Rate(T1,T2) must have T1 and T2 of different types; " "otherwise, it would be a Ratio"); diff --git a/src/base/stl_helpers.hh b/src/base/stl_helpers.hh index 47b817a3d0..d16446d5c3 100644 --- a/src/base/stl_helpers.hh +++ b/src/base/stl_helpers.hh @@ -49,6 +49,9 @@ struct IsHelpedContainer : public std::false_type {}; template struct IsHelpedContainer> : public std::true_type {}; +template +constexpr bool IsHelpedContainerV = IsHelpedContainer::value; + /** * Write out all elements in an stl container as a space separated * list enclosed in square brackets @@ -57,7 +60,7 @@ struct IsHelpedContainer> : public std::true_type {}; */ template -std::enable_if_t::value, std::ostream &> +std::enable_if_t, std::ostream &> operator<<(std::ostream& out, const T &t) { out << "[ "; diff --git a/src/base/str.hh b/src/base/str.hh index 77eca4b1fe..00409ff3d7 100644 --- a/src/base/str.hh +++ b/src/base/str.hh @@ -136,7 +136,7 @@ __to_number(const std::string &value) } template -typename std::enable_if_t::value, T> +typename std::enable_if_t, T> __to_number(const std::string &value) { auto r = __to_number>(value); @@ -144,7 +144,7 @@ __to_number(const std::string &value) } template -typename std::enable_if_t::value, T> +typename std::enable_if_t, T> __to_number(const std::string &value) { // start big and narrow it down if needed @@ -166,10 +166,10 @@ __to_number(const std::string &value) * @return True if the parsing was successful */ template -inline std::enable_if_t<(std::is_integral::value || - std::is_floating_point::value || - std::is_enum::value) && - !std::is_same::value, bool> +inline std::enable_if_t<(std::is_integral_v || + std::is_floating_point_v || + std::is_enum_v) && + !std::is_same_v, bool> to_number(const std::string &value, T &retval) { try { diff --git a/src/base/trie.hh b/src/base/trie.hh index 80ffbc07ff..477bfbde14 100644 --- a/src/base/trie.hh +++ b/src/base/trie.hh @@ -54,8 +54,7 @@ template class Trie { protected: - static_assert(std::is_integral::value, - "Key has to be an integral type"); + static_assert(std::is_integral_v, "Key has to be an integral type"); struct Node { diff --git a/src/cpu/inst_res.hh b/src/cpu/inst_res.hh index f58bf88044..cfdaa154c3 100644 --- a/src/cpu/inst_res.hh +++ b/src/cpu/inst_res.hh @@ -80,12 +80,11 @@ class InstResult /** Scalar result from scalar. */ template explicit InstResult(T i, const ResultType& t) : type(t) { - static_assert(std::is_integral::value ^ - std::is_floating_point::value, + static_assert(std::is_integral_v ^ std::is_floating_point_v, "Parameter type is neither integral nor fp, or it is both"); - if (std::is_integral::value) { + if (std::is_integral_v) { result.integer = i; - } else if (std::is_floating_point::value) { + } else if (std::is_floating_point_v) { result.dbl = i; } } diff --git a/src/dev/reg_bank.hh b/src/dev/reg_bank.hh index 44df906e64..42af7bce89 100644 --- a/src/dev/reg_bank.hh +++ b/src/dev/reg_bank.hh @@ -943,8 +943,8 @@ using RegisterBankBE = RegisterBank; // Delegate serialization to the individual RegisterBase subclasses. template -struct ParseParam::value>> +struct ParseParam>> { static bool parse(const std::string &s, T &value) @@ -954,8 +954,8 @@ struct ParseParam -struct ShowParam::value>> +struct ShowParam>> { static void show(std::ostream &os, const T &value) diff --git a/src/dev/virtio/base.hh b/src/dev/virtio/base.hh index 0e173e2395..41ebb741d1 100644 --- a/src/dev/virtio/base.hh +++ b/src/dev/virtio/base.hh @@ -72,7 +72,7 @@ class VirtQueue; */ template -inline std::enable_if_t::value, T> +inline std::enable_if_t, T> swap_byte(T v) { v.id = swap_byte(v.id); @@ -81,7 +81,7 @@ swap_byte(T v) } template -inline std::enable_if_t::value, T> +inline std::enable_if_t, T> swap_byte(T v) { v.addr = swap_byte(v.addr); diff --git a/src/mem/cache/compressors/dictionary_compressor.hh b/src/mem/cache/compressors/dictionary_compressor.hh index b743aa089b..c283280980 100644 --- a/src/mem/cache/compressors/dictionary_compressor.hh +++ b/src/mem/cache/compressors/dictionary_compressor.hh @@ -179,7 +179,7 @@ class DictionaryCompressor : public BaseDictionaryCompressor template struct Factory { - static_assert(std::is_base_of::value, + static_assert(std::is_base_of_v, "The last pattern must always be derived from the uncompressed " "pattern."); diff --git a/src/mem/cache/prefetch/associative_set.hh b/src/mem/cache/prefetch/associative_set.hh index f7d68a345b..7fbbf879e4 100644 --- a/src/mem/cache/prefetch/associative_set.hh +++ b/src/mem/cache/prefetch/associative_set.hh @@ -44,7 +44,7 @@ namespace gem5 template class AssociativeSet { - static_assert(std::is_base_of::value, + static_assert(std::is_base_of_v, "Entry must derive from TaggedEntry"); /** Associativity of the container */ diff --git a/src/mem/cache/queue.hh b/src/mem/cache/queue.hh index cdfbdd6747..9a770d1f7a 100644 --- a/src/mem/cache/queue.hh +++ b/src/mem/cache/queue.hh @@ -69,7 +69,7 @@ namespace gem5 template class Queue : public Drainable, public Named { - static_assert(std::is_base_of::value, + static_assert(std::is_base_of_v, "Entry must be derived from QueueEntry"); protected: diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py index 8d057c6eaf..582c651cb0 100644 --- a/src/python/m5/SimObject.py +++ b/src/python/m5/SimObject.py @@ -854,8 +854,8 @@ module_init(py::module_ &m_internal) # constructor. code('template ') code('class Dummy${cls}Shunt::value>>') + code(' std::is_constructible_v>>') code('{') code(' public:') code(' using Params = ${cls}Params;') @@ -871,8 +871,8 @@ module_init(py::module_ &m_internal) # not exist. code('template ') code('class Dummy${cls}Shunt::value>>') + code(' !std::is_constructible_v>>') code('{') code(' public:') code(' using Params = Dummy${cls}ParamsClass;') diff --git a/src/sim/byteswap.hh b/src/sim/byteswap.hh index 222c2c2524..031386fdc1 100644 --- a/src/sim/byteswap.hh +++ b/src/sim/byteswap.hh @@ -112,7 +112,7 @@ swap_byte16(uint16_t x) template inline std::enable_if_t< - sizeof(T) == 8 && std::is_convertible::value, T> + sizeof(T) == 8 && std::is_convertible_v, T> swap_byte(T x) { return swap_byte64((uint64_t)x); @@ -120,7 +120,7 @@ swap_byte(T x) template inline std::enable_if_t< - sizeof(T) == 4 && std::is_convertible::value, T> + sizeof(T) == 4 && std::is_convertible_v, T> swap_byte(T x) { return swap_byte32((uint32_t)x); @@ -128,7 +128,7 @@ swap_byte(T x) template inline std::enable_if_t< - sizeof(T) == 2 && std::is_convertible::value, T> + sizeof(T) == 2 && std::is_convertible_v, T> swap_byte(T x) { return swap_byte16((uint16_t)x); @@ -136,7 +136,7 @@ swap_byte(T x) template inline std::enable_if_t< - sizeof(T) == 1 && std::is_convertible::value, T> + sizeof(T) == 1 && std::is_convertible_v, T> swap_byte(T x) { return x; @@ -145,10 +145,10 @@ swap_byte(T x) // Make the function visible in case we need to declare a version of it for // other types template -std::enable_if_t::value, T> +std::enable_if_t, T> swap_byte(T v); template -std::enable_if_t::value, T> +std::enable_if_t, T> swap_byte(T v); template diff --git a/src/sim/guest_abi.test.cc b/src/sim/guest_abi.test.cc index 7ba57ac13c..5b59874c3e 100644 --- a/src/sim/guest_abi.test.cc +++ b/src/sim/guest_abi.test.cc @@ -116,7 +116,7 @@ struct Argument template struct Argument::value>> + typename std::enable_if_t>> { static Arg get(ThreadContext *tc, TestABI_1D::State &state) @@ -137,7 +137,7 @@ struct Result template struct Result::value>> + typename std::enable_if_t>> { static void store(ThreadContext *tc, const Ret &ret) @@ -191,7 +191,7 @@ struct Argument template struct Argument::value>> + typename std::enable_if_t>> { static Arg get(ThreadContext *tc, TestABI_2D::State &state) @@ -212,7 +212,7 @@ struct Result template struct Result::value>> + typename std::enable_if_t>> { static void store(ThreadContext *tc, const Ret &ret) @@ -399,11 +399,11 @@ TEST(GuestABITest, dumpSimcall) TEST(GuestABITest, isVarArgs) { - EXPECT_TRUE(guest_abi::IsVarArgs>::value); - EXPECT_FALSE(guest_abi::IsVarArgs::value); - EXPECT_FALSE(guest_abi::IsVarArgs::value); + EXPECT_TRUE(guest_abi::IsVarArgsV>); + EXPECT_FALSE(guest_abi::IsVarArgsV); + EXPECT_FALSE(guest_abi::IsVarArgsV); struct FooStruct {}; - EXPECT_FALSE(guest_abi::IsVarArgs::value); + EXPECT_FALSE(guest_abi::IsVarArgsV); union FooUnion {}; - EXPECT_FALSE(guest_abi::IsVarArgs::value); + EXPECT_FALSE(guest_abi::IsVarArgsV); } diff --git a/src/sim/guest_abi/layout.hh b/src/sim/guest_abi/layout.hh index ed86f57db3..314bdadb32 100644 --- a/src/sim/guest_abi/layout.hh +++ b/src/sim/guest_abi/layout.hh @@ -58,7 +58,7 @@ struct StateInitializer template struct StateInitializer::value>> + std::is_constructible_v>> { static typename ABI::State init(const ThreadContext *tc) @@ -144,8 +144,9 @@ struct ResultStorer template struct ResultStorer::store)>::value>> + std::is_same_v::store)>>> { static void store(ThreadContext *tc, const Ret &ret, typename ABI::State &state) diff --git a/src/sim/guest_abi/varargs.hh b/src/sim/guest_abi/varargs.hh index a0f6b4ee5e..9bb04786ff 100644 --- a/src/sim/guest_abi/varargs.hh +++ b/src/sim/guest_abi/varargs.hh @@ -176,6 +176,9 @@ struct IsVarArgs : public std::false_type {}; template struct IsVarArgs> : public std::true_type {}; +template +constexpr bool IsVarArgsV = IsVarArgs::value; + template std::ostream & operator << (std::ostream &os, const VarArgs &va) diff --git a/src/sim/proxy_ptr.hh b/src/sim/proxy_ptr.hh index 4fe435534d..03ab9472c9 100644 --- a/src/sim/proxy_ptr.hh +++ b/src/sim/proxy_ptr.hh @@ -137,16 +137,16 @@ class ConstProxyPtr using Type = T; template ::value, int> = 0> + typename std::enable_if_t, int> = 0> explicit ConstProxyPtr(Addr _ptr, Args&&... args) : proxy(std::make_shared(args...)) { setAddr(_ptr); } template ::value, int> = 0> + typename std::enable_if_t, int> = 0> explicit ConstProxyPtr(Args&&... args) : proxy(std::make_shared(args...)) { @@ -154,7 +154,7 @@ class ConstProxyPtr } template ::value>> + typename std::enable_if_t>> ConstProxyPtr(const ConstProxyPtr &other) : proxy(other.proxy), buffer(other.buffer) {} @@ -174,14 +174,14 @@ class ConstProxyPtr operator bool() const { return (bool)buffer; } template - typename std::enable_if_t::value, CPP> + typename std::enable_if_t, CPP> operator + (A a) const { return CPP(addr() + a * sizeof(T), proxy); } template - typename std::enable_if_t::value, CPP> + typename std::enable_if_t, CPP> operator - (A a) const { return CPP(addr() - a * sizeof(T), proxy); @@ -228,7 +228,7 @@ class ConstProxyPtr }; template -typename std::enable_if_t::value, ConstProxyPtr> +typename std::enable_if_t, ConstProxyPtr> operator + (A a, const ConstProxyPtr &other) { return other + a; @@ -245,17 +245,17 @@ class ProxyPtr : public ConstProxyPtr public: template ::value, int> = 0> + typename std::enable_if_t, int> = 0> explicit ProxyPtr(Addr _ptr, Args&&... args) : CPP(_ptr, args...) {} template ::value, int> = 0> + typename std::enable_if_t, int> = 0> explicit ProxyPtr(Args&&... args) : CPP(0, args...) {} template ::value && - !std::is_same::value>> + typename std::enable_if_t && + !std::is_same_v>> ProxyPtr(const ProxyPtr &other) : CPP(other) {} ProxyPtr(const PP &other) : CPP(other) {} @@ -269,14 +269,14 @@ class ProxyPtr : public ConstProxyPtr } template - typename std::enable_if_t::value, PP> + typename std::enable_if_t, PP> operator + (A a) const { return PP(this->addr() + a * sizeof(T), this->proxy); } template - typename std::enable_if_t::value, PP> + typename std::enable_if_t, PP> operator - (A a) const { return PP(this->addr() - a * sizeof(T), this->proxy); @@ -351,7 +351,7 @@ class ProxyPtr }; template -typename std::enable_if_t::value, ProxyPtr> +typename std::enable_if_t, ProxyPtr> operator + (A a, const ProxyPtr &other) { return other + a; diff --git a/src/sim/proxy_ptr.test.cc b/src/sim/proxy_ptr.test.cc index d93df14d68..6f49d166e2 100644 --- a/src/sim/proxy_ptr.test.cc +++ b/src/sim/proxy_ptr.test.cc @@ -341,7 +341,7 @@ TEST(ProxyPtr, ConstOperators) EXPECT_EQ((const PtrType *)null, nullptr); // Dereferences. - is_same = std::is_same::value; + is_same = std::is_same_v; EXPECT_TRUE(is_same); store.store[0x100] = 0x55; @@ -373,7 +373,7 @@ TEST(ProxyPtr, ConstOperators) EXPECT_EQ(struct_ptr->c, 0x33); EXPECT_EQ(struct_ptr->d, 0x44); - is_same = std::is_samea)), const uint8_t &>::value; + is_same = std::is_same_va)), const uint8_t &>; EXPECT_TRUE(is_same); } @@ -426,7 +426,7 @@ TEST(ProxyPtr, NonConstOperators) EXPECT_EQ((const PtrType *)null, nullptr); // Dereferences. - is_same = std::is_same::value; + is_same = std::is_same_v; EXPECT_TRUE(is_same); // Flush test_ptr1, which has been conservatively marked as dirty. @@ -461,7 +461,7 @@ TEST(ProxyPtr, NonConstOperators) EXPECT_EQ(struct_ptr->c, 0x33); EXPECT_EQ(struct_ptr->d, 0x44); - is_same = std::is_samea)), uint8_t &>::value; + is_same = std::is_same_va)), uint8_t &>; EXPECT_TRUE(is_same); } diff --git a/src/sim/serialize_handlers.hh b/src/sim/serialize_handlers.hh index 6802b913c5..10d5a185f5 100644 --- a/src/sim/serialize_handlers.hh +++ b/src/sim/serialize_handlers.hh @@ -130,14 +130,14 @@ struct ShowParam // Handle characters specially so that we print their value, not the character // they encode. template -struct ShowParam::value || - std::is_same::value || - std::is_same::value>> +struct ShowParam || + std::is_same_v || + std::is_same_v>> { static void show(std::ostream &os, const T &value) { - if (std::is_signed::value) + if (std::is_signed_v) os << (int)value; else os << (unsigned int)value; diff --git a/src/sim/syscall_abi.hh b/src/sim/syscall_abi.hh index f51b178b3c..d50286fb79 100644 --- a/src/sim/syscall_abi.hh +++ b/src/sim/syscall_abi.hh @@ -62,6 +62,9 @@ struct GenericSyscallABI32 : public GenericSyscallABI public std::true_type {}; + template + static constexpr bool IsWideV = IsWide::value; + // Read two registers and merge them into one value. static uint64_t mergeRegs(ThreadContext *tc, RegIndex low_idx, RegIndex high_idx) @@ -80,8 +83,8 @@ namespace guest_abi template struct Argument::value && - std::is_integral::value>> + std::is_base_of_v && + std::is_integral_v>> { static Arg get(ThreadContext *tc, typename ABI::State &state) @@ -96,8 +99,8 @@ struct Argument struct Argument::value && - !ABI::template IsWide::value>> + typename std::enable_if_t && + !ABI::template IsWideV>> { static Arg get(ThreadContext *tc, typename ABI::State &state)