@@ -268,16 +268,59 @@ define void @foo({i32, i8} %v0) {
268268
269269TEST_F (SandboxTypeTest, VectorType) {
270270 parseIR (C, R"IR(
271- define void @foo(<2 x i8 > %v0 ) {
271+ define void @foo(<4 x i16 > %vi0, <4 x float> %vf1, i8 %i0 ) {
272272 ret void
273273}
274274)IR" );
275275 llvm::Function *LLVMF = &*M->getFunction (" foo" );
276276 sandboxir::Context Ctx (C);
277277 auto *F = Ctx.createFunction (LLVMF);
278- // Check classof(), creation.
279- [[maybe_unused]] auto *VecTy =
280- cast<sandboxir::VectorType>(F->getArg (0 )->getType ());
278+ // Check classof(), creation, accessors
279+ auto *VecTy = cast<sandboxir::VectorType>(F->getArg (0 )->getType ());
280+ EXPECT_TRUE (VecTy->getElementType ()->isIntegerTy (16 ));
281+ EXPECT_EQ (VecTy->getElementCount (), ElementCount::getFixed (4 ));
282+
283+ // get(ElementType, NumElements, Scalable)
284+ EXPECT_EQ (sandboxir::VectorType::get (sandboxir::Type::getInt16Ty (Ctx), 4 ,
285+ /* Scalable=*/ false ),
286+ F->getArg (0 )->getType ());
287+ // get(ElementType, Other)
288+ EXPECT_EQ (sandboxir::VectorType::get (
289+ sandboxir::Type::getInt16Ty (Ctx),
290+ cast<sandboxir::VectorType>(F->getArg (0 )->getType ())),
291+ F->getArg (0 )->getType ());
292+ auto *FVecTy = cast<sandboxir::VectorType>(F->getArg (1 )->getType ());
293+ EXPECT_TRUE (FVecTy->getElementType ()->isFloatTy ());
294+ // getInteger
295+ auto *IVecTy = sandboxir::VectorType::getInteger (FVecTy);
296+ EXPECT_TRUE (IVecTy->getElementType ()->isIntegerTy (32 ));
297+ EXPECT_EQ (IVecTy->getElementCount (), FVecTy->getElementCount ());
298+ // getExtendedElementCountVectorType
299+ auto *ExtVecTy = sandboxir::VectorType::getExtendedElementVectorType (IVecTy);
300+ EXPECT_TRUE (ExtVecTy->getElementType ()->isIntegerTy (64 ));
301+ EXPECT_EQ (ExtVecTy->getElementCount (), VecTy->getElementCount ());
302+ // getTruncatedElementVectorType
303+ auto *TruncVecTy =
304+ sandboxir::VectorType::getTruncatedElementVectorType (IVecTy);
305+ EXPECT_TRUE (TruncVecTy->getElementType ()->isIntegerTy (16 ));
306+ EXPECT_EQ (TruncVecTy->getElementCount (), VecTy->getElementCount ());
307+ // getSubdividedVectorType
308+ auto *SubVecTy = sandboxir::VectorType::getSubdividedVectorType (VecTy, 1 );
309+ EXPECT_TRUE (SubVecTy->getElementType ()->isIntegerTy (8 ));
310+ EXPECT_EQ (SubVecTy->getElementCount (), ElementCount::getFixed (8 ));
311+ // getHalfElementsVectorType
312+ auto *HalfVecTy = sandboxir::VectorType::getHalfElementsVectorType (VecTy);
313+ EXPECT_TRUE (HalfVecTy->getElementType ()->isIntegerTy (16 ));
314+ EXPECT_EQ (HalfVecTy->getElementCount (), ElementCount::getFixed (2 ));
315+ // getDoubleElementsVectorType
316+ auto *DoubleVecTy = sandboxir::VectorType::getDoubleElementsVectorType (VecTy);
317+ EXPECT_TRUE (DoubleVecTy->getElementType ()->isIntegerTy (16 ));
318+ EXPECT_EQ (DoubleVecTy->getElementCount (), ElementCount::getFixed (8 ));
319+ // isValidElementType
320+ auto *I8Type = F->getArg (2 )->getType ();
321+ EXPECT_TRUE (I8Type->isIntegerTy ());
322+ EXPECT_TRUE (sandboxir::VectorType::isValidElementType (I8Type));
323+ EXPECT_FALSE (sandboxir::VectorType::isValidElementType (FVecTy));
281324}
282325
283326TEST_F (SandboxTypeTest, FunctionType) {
0 commit comments