Skip to content

[SandboxIR] Implement SelectInst #99996

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 1 commit into from
Jul 23, 2024
Merged

[SandboxIR] Implement SelectInst #99996

merged 1 commit into from
Jul 23, 2024

Conversation

vporpo
Copy link
Contributor

@vporpo vporpo commented Jul 22, 2024

This patch implements sandboxir::SelectInst which mirrors llvm::SelectInst.

@vporpo
Copy link
Contributor Author

vporpo commented Jul 22, 2024

I just realized I need to add some tests to exercise the create() functions.

if (auto *NewSI = dyn_cast<llvm::SelectInst>(NewV))
return Ctx.createSelectInst(NewSI);
assert(isa<llvm::Constant>(NewV) && "Expected constant");
return Ctx.getOrCreateConstant(cast<llvm::Constant>(NewV));
Copy link
Member

Choose a reason for hiding this comment

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

Maybe a createCommon here too like ReturnInst to capture the duplication?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes.

{
// Check SelectInst::create() InsertAtEnd.
auto *NewSel = cast<sandboxir::SelectInst>(
sandboxir::SelectInst::create(Cond0, V0, V1, /*InsertAtEnd=*/BB, Ctx));
Copy link
Member

Choose a reason for hiding this comment

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

Would it be worth checking *(BB->end())->getOpcodeName() == Select here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, this is automatically handled by the .def files, so it shouldn't normally be wrong. But yeah, at some point we should check this too.
It will be checked once we add tests for the dump() functions for the whole class hierarchy in a future patch.

Copy link
Member

@tmsri tmsri left a comment

Choose a reason for hiding this comment

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

Fine after addressing some minor comments. Very similar to other instruction classes.

This patch implements sandboxir::SelectInst which mirrors llvm::SelectInst.
@vporpo vporpo merged commit 73ffeea into llvm:main Jul 23, 2024
4 of 6 checks passed
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
Summary:
This patch implements sandboxir::SelectInst which mirrors
llvm::SelectInst.

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60250785
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