[llvm] [SandboxIR] Add missing VectorType functions (PR #107650)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 6 15:54:18 PDT 2024


================
@@ -268,16 +268,49 @@ define void @foo({i32, i8} %v0) {
 
 TEST_F(SandboxTypeTest, VectorType) {
   parseIR(C, R"IR(
-define void @foo(<2 x i8> %v0) {
+define void @foo(<4 x i16> %vi0, <4 x float> %vf1, i8 %i0) {
   ret void
 }
 )IR");
   llvm::Function *LLVMF = &*M->getFunction("foo");
   sandboxir::Context Ctx(C);
   auto *F = Ctx.createFunction(LLVMF);
-  // Check classof(), creation.
-  [[maybe_unused]] auto *VecTy =
-      cast<sandboxir::VectorType>(F->getArg(0)->getType());
+  // Check classof(), creation, accessors
+  auto *VecTy = cast<sandboxir::VectorType>(F->getArg(0)->getType());
+  EXPECT_TRUE(VecTy->getElementType()->isIntegerTy(16));
+  EXPECT_EQ(VecTy->getElementCount(), ElementCount::getFixed(4));
+
+  auto *FVecTy = cast<sandboxir::VectorType>(F->getArg(1)->getType());
+  EXPECT_TRUE(FVecTy->getElementType()->isFloatTy());
+  auto *IVecTy = sandboxir::VectorType::getInteger(Ctx, FVecTy);
+  EXPECT_TRUE(IVecTy->getElementType()->isIntegerTy(32));
+  EXPECT_EQ(IVecTy->getElementCount(), FVecTy->getElementCount());
+
+  auto *ExtVecTy =
----------------
vporpo wrote:

nit: I usually add a comment mentioning the function being tested. This makes the test a bit more readable, especially in cases where you a check spans multiple lines of code. In this case something like `// getExtendedVectorType`

https://github.com/llvm/llvm-project/pull/107650


More information about the llvm-commits mailing list