-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[VPlan] Add VPInst::getNumOperandsForOpcode, use to verify in ctor (NFC) #142284
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
Changes from 1 commit
2ab3df5
cd2f291
f58eadd
c134f89
e78eb44
0d8c982
ef1ba88
d2f5c26
0c8de77
031aeca
f829e30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -967,6 +967,13 @@ class VPInstruction : public VPRecipeWithIRFlags, | |
| /// value for lane \p Lane. | ||
| Value *generatePerLane(VPTransformState &State, const VPLane &Lane); | ||
|
|
||
| #if !defined(NDEBUG) | ||
| /// Return the number of operands determined by the opcode of the | ||
| /// VPInstruction. Returns -1 if the number of operands cannot be determined | ||
| /// directly by the opcode. | ||
| unsigned getNumOperandsForOpcode() const; | ||
|
||
| #endif | ||
|
|
||
| public: | ||
| VPInstruction(unsigned Opcode, ArrayRef<VPValue *> Operands, DebugLoc DL = {}, | ||
| const Twine &Name = "") | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -413,8 +413,62 @@ VPInstruction::VPInstruction(unsigned Opcode, ArrayRef<VPValue *> Operands, | |||||||||
| Opcode(Opcode), Name(Name.str()) { | ||||||||||
| assert(flagsValidForOpcode(getOpcode()) && | ||||||||||
| "Set flags not supported for the provided opcode"); | ||||||||||
| assert((getNumOperandsForOpcode() == -1u || | ||||||||||
| getNumOperandsForOpcode() == getNumOperands()) && | ||||||||||
| "number of operands does not match opcode"); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| #ifndef NDEBUG | ||||||||||
| unsigned VPInstruction::getNumOperandsForOpcode() const { | ||||||||||
| if (Instruction::isUnaryOp(getOpcode()) || Instruction::isCast(getOpcode())) | ||||||||||
| return 1; | ||||||||||
|
|
||||||||||
| if (Instruction::isBinaryOp(getOpcode())) | ||||||||||
| return 2; | ||||||||||
|
|
||||||||||
| switch (getOpcode()) { | ||||||||||
| case VPInstruction::StepVector: | ||||||||||
| return 0; | ||||||||||
| case Instruction::Alloca: | ||||||||||
| case Instruction::ExtractValue: | ||||||||||
| case Instruction::Freeze: | ||||||||||
| case Instruction::Load: | ||||||||||
| case VPInstruction::AnyOf: | ||||||||||
| case VPInstruction::BranchOnCond: | ||||||||||
| case VPInstruction::CalculateTripCountMinusVF: | ||||||||||
| case VPInstruction::CanonicalIVIncrementForPart: | ||||||||||
| case VPInstruction::ExplicitVectorLength: | ||||||||||
| case VPInstruction::ExtractLastElement: | ||||||||||
| case VPInstruction::ExtractPenultimateElement: | ||||||||||
| case VPInstruction::FirstActiveLane: | ||||||||||
| case VPInstruction::Not: | ||||||||||
| return 1; | ||||||||||
|
|
||||||||||
|
||||||||||
consistency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done thanks
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| case VPInstruction::WideIVStep: | |
| case VPInstruction::PtrAdd: | |
| case VPInstruction::PtrAdd: | |
| case VPInstruction::WideIVStep: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flipped, thanks
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| case Instruction::PHI: | |
| case Instruction::GetElementPtr: | |
| case Instruction::GetElementPtr: | |
| case Instruction::PHI: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flipped, thanks!
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How/is this related to introducing getNumOperandsForOpcode() (i.e., rest of patch)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was unrelated, removed ,thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done thanks