[llvm] [VPlan] Add specialized VPValue subclasses for different types (NFC) (PR #172758)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 31 16:09:13 PST 2025
================
@@ -129,11 +124,36 @@ void VPDef::dump() const {
#endif
VPRecipeBase *VPValue::getDefiningRecipe() {
- return cast_or_null<VPRecipeBase>(Def);
+ auto *DefValue = dyn_cast<VPRecipeValue>(this);
+ if (!DefValue)
+ return nullptr;
+ return cast<VPRecipeBase>(DefValue->Def);
}
const VPRecipeBase *VPValue::getDefiningRecipe() const {
- return cast_or_null<VPRecipeBase>(Def);
+ auto *DefValue = dyn_cast<VPRecipeValue>(this);
+ if (!DefValue)
+ return nullptr;
+ assert(DefValue);
+ return cast<VPRecipeBase>(DefValue->Def);
+}
+
+Value *VPValue::getLiveInIRValue() const {
+ return cast<VPIRValue>(this)->getValue();
+}
+
+Type *VPIRValue::getType() const { return getUnderlyingValue()->getType(); }
+
+VPRecipeValue::VPRecipeValue(VPDef *Def, Value *UV)
+ : VPValue(VPVDefValueSC, UV, nullptr), Def(Def) {
+ assert(Def && "VPRecipeValue requires a defining recipe");
+ Def->addDefinedValue(this);
+}
+
+VPRecipeValue::~VPRecipeValue() {
+ assert(Users.empty() && "trying to delete a VPValue with remaining users");
----------------
ayalz wrote:
Suffice to have this assert at ~VPValue()? Or update comment to say VPRecipeValue.
https://github.com/llvm/llvm-project/pull/172758
More information about the llvm-commits
mailing list