Home | History | Annotate | Download | only in arm64
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #include "instruction_set_features_arm64.h"
     18 
     19 #include <gtest/gtest.h>
     20 
     21 namespace art {
     22 
     23 TEST(Arm64InstructionSetFeaturesTest, Arm64Features) {
     24   // Build features for an ARM64 processor.
     25   std::string error_msg;
     26   std::unique_ptr<const InstructionSetFeatures> arm64_features(
     27       InstructionSetFeatures::FromVariant(kArm64, "default", &error_msg));
     28   ASSERT_TRUE(arm64_features.get() != nullptr) << error_msg;
     29   EXPECT_EQ(arm64_features->GetInstructionSet(), kArm64);
     30   EXPECT_TRUE(arm64_features->Equals(arm64_features.get()));
     31   EXPECT_STREQ("a53", arm64_features->GetFeatureString().c_str());
     32   EXPECT_EQ(arm64_features->AsBitmap(), 1U);
     33 
     34   std::unique_ptr<const InstructionSetFeatures> cortex_a57_features(
     35       InstructionSetFeatures::FromVariant(kArm64, "cortex-a57", &error_msg));
     36   ASSERT_TRUE(cortex_a57_features.get() != nullptr) << error_msg;
     37   EXPECT_EQ(cortex_a57_features->GetInstructionSet(), kArm64);
     38   EXPECT_TRUE(cortex_a57_features->Equals(cortex_a57_features.get()));
     39   EXPECT_STREQ("a53", cortex_a57_features->GetFeatureString().c_str());
     40   EXPECT_EQ(cortex_a57_features->AsBitmap(), 1U);
     41 
     42   std::unique_ptr<const InstructionSetFeatures> cortex_a73_features(
     43       InstructionSetFeatures::FromVariant(kArm64, "cortex-a73", &error_msg));
     44   ASSERT_TRUE(cortex_a73_features.get() != nullptr) << error_msg;
     45   EXPECT_EQ(cortex_a73_features->GetInstructionSet(), kArm64);
     46   EXPECT_TRUE(cortex_a73_features->Equals(cortex_a73_features.get()));
     47   EXPECT_STREQ("a53", cortex_a73_features->GetFeatureString().c_str());
     48   EXPECT_EQ(cortex_a73_features->AsBitmap(), 1U);
     49 
     50   std::unique_ptr<const InstructionSetFeatures> cortex_a35_features(
     51       InstructionSetFeatures::FromVariant(kArm64, "cortex-a35", &error_msg));
     52   ASSERT_TRUE(cortex_a35_features.get() != nullptr) << error_msg;
     53   EXPECT_EQ(cortex_a35_features->GetInstructionSet(), kArm64);
     54   EXPECT_TRUE(cortex_a35_features->Equals(cortex_a35_features.get()));
     55   EXPECT_STREQ("-a53", cortex_a35_features->GetFeatureString().c_str());
     56   EXPECT_EQ(cortex_a35_features->AsBitmap(), 0U);
     57 
     58   std::unique_ptr<const InstructionSetFeatures> kryo_features(
     59       InstructionSetFeatures::FromVariant(kArm64, "kryo", &error_msg));
     60   ASSERT_TRUE(kryo_features.get() != nullptr) << error_msg;
     61   EXPECT_EQ(kryo_features->GetInstructionSet(), kArm64);
     62   EXPECT_TRUE(kryo_features->Equals(kryo_features.get()));
     63   EXPECT_TRUE(kryo_features->Equals(cortex_a35_features.get()));
     64   EXPECT_FALSE(kryo_features->Equals(cortex_a57_features.get()));
     65   EXPECT_STREQ("-a53", kryo_features->GetFeatureString().c_str());
     66   EXPECT_EQ(kryo_features->AsBitmap(), 0U);
     67 }
     68 
     69 }  // namespace art
     70