diff --git a/src/arch/arm/SConscript b/src/arch/arm/SConscript index e51437e49c..73ebcacf20 100644 --- a/src/arch/arm/SConscript +++ b/src/arch/arm/SConscript @@ -44,6 +44,8 @@ if env['TARGET_ISA'] == 'arm': # Workaround for bug in SCons version > 0.97d20071212 # Scons bug id: 2006 M5 Bug id: 308 Dir('isa/formats') + + GTest('aapcs64.test', 'aapcs64.test.cc') Source('decoder.cc') Source('faults.cc') Source('insts/branch.cc') diff --git a/src/arch/arm/aapcs64.test.cc b/src/arch/arm/aapcs64.test.cc new file mode 100644 index 0000000000..69bbb837d2 --- /dev/null +++ b/src/arch/arm/aapcs64.test.cc @@ -0,0 +1,118 @@ +/* + * Copyright 2020 Google, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +#include "arch/arm/aapcs64.hh" + +TEST(Aapcs64, IsAapcs64ShortVector) +{ + using Scalar = uint64_t; + using TooShort = uint8_t[2]; + using TooLong = uint16_t[32]; + using TooLongFloat = double[4]; + using EightLong = uint32_t[2]; + using SixteenLong = uint64_t[2]; + using EightLongFloat = float[2]; + using SixteenLongFloat = double[2]; + + EXPECT_FALSE(GuestABI::IsAapcs64ShortVector::value); + EXPECT_FALSE(GuestABI::IsAapcs64ShortVector::value); + EXPECT_FALSE(GuestABI::IsAapcs64ShortVector::value); + EXPECT_FALSE(GuestABI::IsAapcs64ShortVector::value); + EXPECT_FALSE(GuestABI::IsAapcs64ShortVector::value); + + EXPECT_TRUE(GuestABI::IsAapcs64ShortVector::value); + EXPECT_TRUE(GuestABI::IsAapcs64ShortVector::value); + EXPECT_TRUE(GuestABI::IsAapcs64ShortVector::value); + EXPECT_TRUE(GuestABI::IsAapcs64ShortVector::value); +} + +TEST(Aapcs64, IsAapcs64Hfa) +{ + // Accept floating point arrays with up to 4 members. + EXPECT_TRUE(GuestABI::IsAapcs64Hfa::value); + EXPECT_TRUE(GuestABI::IsAapcs64Hfa::value); + EXPECT_TRUE(GuestABI::IsAapcs64Hfa::value); + EXPECT_TRUE(GuestABI::IsAapcs64Hfa::value); + + EXPECT_TRUE(GuestABI::IsAapcs64Hfa::value); + EXPECT_TRUE(GuestABI::IsAapcs64Hfa::value); + EXPECT_TRUE(GuestABI::IsAapcs64Hfa::value); + EXPECT_TRUE(GuestABI::IsAapcs64Hfa::value); + + // Too many members. + EXPECT_FALSE(GuestABI::IsAapcs64Hfa::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hfa::value); + + // Wrong type of members, or not arrays. + EXPECT_FALSE(GuestABI::IsAapcs64Hfa::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hfa::value); + struct Struct {}; + EXPECT_FALSE(GuestABI::IsAapcs64Hfa::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hfa::value); +} + +TEST(Aapcs64, IsAapcs64Hva) +{ + using SvaInt = uint32_t[2]; + using SvaTiny = uint8_t[16]; + using SvaFloat = float[2]; + + EXPECT_TRUE(GuestABI::IsAapcs64Hva::value); + EXPECT_TRUE(GuestABI::IsAapcs64Hva::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hva::value); + + EXPECT_TRUE(GuestABI::IsAapcs64Hva::value); + EXPECT_TRUE(GuestABI::IsAapcs64Hva::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hva::value); + + EXPECT_TRUE(GuestABI::IsAapcs64Hva::value); + EXPECT_TRUE(GuestABI::IsAapcs64Hva::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hva::value); + + EXPECT_FALSE(GuestABI::IsAapcs64Hva::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hva::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hva::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hva::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hva::value); +} + +TEST(Aapcs64, IsAapcs64Hxa) +{ + using SvaInt = uint32_t[2]; + + EXPECT_TRUE(GuestABI::IsAapcs64Hxa::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hxa::value); + + EXPECT_TRUE(GuestABI::IsAapcs64Hxa::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hxa::value); + + EXPECT_FALSE(GuestABI::IsAapcs64Hxa::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hxa::value); + EXPECT_FALSE(GuestABI::IsAapcs64Hxa::value); +}