1 //===- VecUtilsTest.cpp --------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "llvm/Transforms/Vectorize/SandboxVectorizer/VecUtils.h" 10 #include "llvm/AsmParser/Parser.h" 11 #include "llvm/SandboxIR/Context.h" 12 #include "llvm/SandboxIR/Type.h" 13 #include "gtest/gtest.h" 14 15 using namespace llvm; 16 17 struct VecUtilsTest : public testing::Test { 18 LLVMContext C; 19 }; 20 21 TEST_F(VecUtilsTest, GetNumElements) { 22 sandboxir::Context Ctx(C); 23 auto *ElemTy = sandboxir::Type::getInt32Ty(Ctx); 24 EXPECT_EQ(sandboxir::VecUtils::getNumElements(ElemTy), 1); 25 auto *VTy = sandboxir::FixedVectorType::get(ElemTy, 2); 26 EXPECT_EQ(sandboxir::VecUtils::getNumElements(VTy), 2); 27 auto *VTy1 = sandboxir::FixedVectorType::get(ElemTy, 1); 28 EXPECT_EQ(sandboxir::VecUtils::getNumElements(VTy1), 1); 29 } 30 31 TEST_F(VecUtilsTest, GetElementType) { 32 sandboxir::Context Ctx(C); 33 auto *ElemTy = sandboxir::Type::getInt32Ty(Ctx); 34 EXPECT_EQ(sandboxir::VecUtils::getElementType(ElemTy), ElemTy); 35 auto *VTy = sandboxir::FixedVectorType::get(ElemTy, 2); 36 EXPECT_EQ(sandboxir::VecUtils::getElementType(VTy), ElemTy); 37 } 38