Skip to content

[SandboxIR] Add missing VectorType functions #107650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 9, 2024

Conversation

Sterling-Augustine
Copy link
Contributor

Fills in many missing functions from VectorType

inline ElementCount getElementCount() const {
return cast<llvm::VectorType>(LLVMTy)->getElementCount();
}
static VectorType *getInteger(Context &Ctx, VectorType *VTy);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the Ctx argument, you can get it like: VTy->getContext(). Same for the rest of the functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

EXPECT_TRUE(IVecTy->getElementType()->isIntegerTy(32));
EXPECT_EQ(IVecTy->getElementCount(), FVecTy->getElementCount());

auto *ExtVecTy =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return VectorType::get(ElementType,
ElementCount::get(NumElements, Scalable));
}
// Needs tests
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm which tests are missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete stale comment

EXPECT_TRUE(VecTy->getElementType()->isIntegerTy(16));
EXPECT_EQ(VecTy->getElementCount(), ElementCount::getFixed(4));

auto *FVecTy = cast<sandboxir::VectorType>(F->getArg(1)->getType());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we are not testing the new get() functions:

// get(ElementType, NumElements, Scalable)
EXPECT_EQ(VectorType::get(Type::getInt16Ty(Ctx), 4, **/*Scalable=*/false), F>getArg(0)->getType());

// get(ElementType, Other)
EXPECT_EQ(VectorType::get(Type::getInt16Ty(Ctx), F->getArg(0)->getType()), F->getArg(0)->getType());

Copy link
Contributor

@vporpo vporpo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@Sterling-Augustine Sterling-Augustine merged commit 6f8d278 into llvm:main Sep 9, 2024
5 of 7 checks passed
@Sterling-Augustine Sterling-Augustine deleted the vtypes branch September 11, 2024 20:40
@tmsri tmsri self-requested a review September 20, 2024 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants