[llvm] [SandboxIR] Implement FixedVectorType (PR #107930)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 10 15:35:18 PDT 2024
================
@@ -323,6 +323,64 @@ define void @foo(<4 x i16> %vi0, <4 x float> %vf1, i8 %i0) {
EXPECT_FALSE(sandboxir::VectorType::isValidElementType(FVecTy));
}
+TEST_F(SandboxTypeTest, FixedVectorType) {
+ parseIR(C, R"IR(
+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, accessors
+ auto *VecTy = cast<sandboxir::FixedVectorType>(F->getArg(0)->getType());
+ EXPECT_TRUE(VecTy->getElementType()->isIntegerTy(16));
+ EXPECT_EQ(VecTy->getElementCount(), ElementCount::getFixed(4));
+
+ // get(ElementType, NumElements)
+ EXPECT_EQ(
+ sandboxir::FixedVectorType::get(sandboxir::Type::getInt16Ty(Ctx), 4),
+ F->getArg(0)->getType());
+ // get(ElementType, Other)
+ EXPECT_EQ(sandboxir::FixedVectorType::get(
+ sandboxir::Type::getInt16Ty(Ctx),
+ cast<sandboxir::FixedVectorType>(F->getArg(0)->getType())),
+ F->getArg(0)->getType());
+ auto *FVecTy = cast<sandboxir::FixedVectorType>(F->getArg(1)->getType());
+ EXPECT_TRUE(FVecTy->getElementType()->isFloatTy());
+ // getInteger
+ auto *IVecTy = sandboxir::FixedVectorType::getInteger(FVecTy);
+ EXPECT_TRUE(IVecTy->getElementType()->isIntegerTy(32));
+ EXPECT_EQ(IVecTy->getElementCount(), FVecTy->getElementCount());
+ // getExtendedElementCountVectorType
+ auto *ExtVecTy =
+ sandboxir::FixedVectorType::getExtendedElementVectorType(IVecTy);
----------------
Sterling-Augustine wrote:
Done
https://github.com/llvm/llvm-project/pull/107930
More information about the llvm-commits
mailing list