gem5  v20.1.0.0
aapcs64.test.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2020 Google, Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #include <gtest/gtest.h>
29 
30 #include "arch/arm/aapcs64.hh"
31 
32 TEST(Aapcs64, IsAapcs64ShortVector)
33 {
34  using Scalar = uint64_t;
35  using TooShort = uint8_t[2];
36  using TooLong = uint16_t[32];
37  using TooLongFloat = double[4];
38  using EightLong = uint32_t[2];
39  using SixteenLong = uint64_t[2];
40  using EightLongFloat = float[2];
41  using SixteenLongFloat = double[2];
42 
48 
53 }
54 
55 TEST(Aapcs64, IsAapcs64Hfa)
56 {
57  // Accept floating point arrays with up to 4 members.
58  EXPECT_TRUE(GuestABI::IsAapcs64Hfa<float[1]>::value);
59  EXPECT_TRUE(GuestABI::IsAapcs64Hfa<float[2]>::value);
60  EXPECT_TRUE(GuestABI::IsAapcs64Hfa<float[3]>::value);
61  EXPECT_TRUE(GuestABI::IsAapcs64Hfa<float[4]>::value);
62 
63  EXPECT_TRUE(GuestABI::IsAapcs64Hfa<double[1]>::value);
64  EXPECT_TRUE(GuestABI::IsAapcs64Hfa<double[2]>::value);
65  EXPECT_TRUE(GuestABI::IsAapcs64Hfa<double[3]>::value);
66  EXPECT_TRUE(GuestABI::IsAapcs64Hfa<double[4]>::value);
67 
68  // Too many members.
69  EXPECT_FALSE(GuestABI::IsAapcs64Hfa<float[5]>::value);
70  EXPECT_FALSE(GuestABI::IsAapcs64Hfa<double[5]>::value);
71 
72  // Wrong type of members, or not arrays.
73  EXPECT_FALSE(GuestABI::IsAapcs64Hfa<int32_t[3]>::value);
75  struct Struct {};
78 }
79 
80 TEST(Aapcs64, IsAapcs64Hva)
81 {
82  using SvaInt = uint32_t[2];
83  using SvaTiny = uint8_t[16];
84  using SvaFloat = float[2];
85 
86  EXPECT_TRUE(GuestABI::IsAapcs64Hva<SvaInt[3]>::value);
87  EXPECT_TRUE(GuestABI::IsAapcs64Hva<SvaInt[4]>::value);
88  EXPECT_FALSE(GuestABI::IsAapcs64Hva<SvaInt[5]>::value);
89 
90  EXPECT_TRUE(GuestABI::IsAapcs64Hva<SvaFloat[3]>::value);
91  EXPECT_TRUE(GuestABI::IsAapcs64Hva<SvaFloat[4]>::value);
92  EXPECT_FALSE(GuestABI::IsAapcs64Hva<SvaFloat[5]>::value);
93 
94  EXPECT_TRUE(GuestABI::IsAapcs64Hva<SvaTiny[3]>::value);
95  EXPECT_TRUE(GuestABI::IsAapcs64Hva<SvaTiny[4]>::value);
96  EXPECT_FALSE(GuestABI::IsAapcs64Hva<SvaTiny[5]>::value);
97 
98  EXPECT_FALSE(GuestABI::IsAapcs64Hva<uint64_t>::value);
99  EXPECT_FALSE(GuestABI::IsAapcs64Hva<uint64_t[1]>::value);
100  EXPECT_FALSE(GuestABI::IsAapcs64Hva<SvaTiny>::value);
101  EXPECT_FALSE(GuestABI::IsAapcs64Hva<void>::value);
102  EXPECT_FALSE(GuestABI::IsAapcs64Hva<float>::value);
103 }
104 
105 TEST(Aapcs64, IsAapcs64Hxa)
106 {
107  using SvaInt = uint32_t[2];
108 
109  EXPECT_TRUE(GuestABI::IsAapcs64Hxa<SvaInt[4]>::value);
110  EXPECT_FALSE(GuestABI::IsAapcs64Hxa<SvaInt[5]>::value);
111 
112  EXPECT_TRUE(GuestABI::IsAapcs64Hxa<float[4]>::value);
113  EXPECT_FALSE(GuestABI::IsAapcs64Hxa<float[5]>::value);
114 
115  EXPECT_FALSE(GuestABI::IsAapcs64Hxa<SvaInt>::value);
116  EXPECT_FALSE(GuestABI::IsAapcs64Hxa<uint64_t>::value);
117  EXPECT_FALSE(GuestABI::IsAapcs64Hxa<void>::value);
118 }
TEST
TEST(Aapcs64, IsAapcs64ShortVector)
Definition: aapcs64.test.cc:32
aapcs64.hh
GuestABI::IsAapcs64ShortVector
Definition: aapcs64.hh:76
EXPECT_FALSE
#define EXPECT_FALSE(expr)
A macro which verifies that expr evaluates to false.
Definition: unittest.hh:106
Aapcs64
Definition: aapcs64.hh:45
EXPECT_TRUE
#define EXPECT_TRUE(expr)
A macro which verifies that expr evaluates to true.
Definition: unittest.hh:103
GuestABI::IsAapcs64Hfa
Definition: aapcs64.hh:115

Generated on Wed Sep 30 2020 14:01:58 for gem5 by doxygen 1.8.17