[ownership] Make ForwardingOperand truly a loose wrapper around an operand.

This implies making -> and * return an Operand * instead of an
OwnershipForwardingInst. So one can thus do:

ForwardingOperand op;
op.myForwardingOperandMethod();
op->myOperandMethod();
This commit is contained in:
Michael Gottesman
2020-12-30 19:33:10 -08:00
parent 939ae014dd
commit 31c9d769f9
2 changed files with 37 additions and 14 deletions

View File

@@ -82,29 +82,24 @@ class ForwardingOperand {
public:
static Optional<ForwardingOperand> get(Operand *use);
Operand *getUse() const { return use; }
OwnershipConstraint getOwnershipConstraint() const {
// We use a force unwrap since a ForwardingOperand should always have an
// ownership constraint.
return use->getOwnershipConstraint();
}
ValueOwnershipKind getOwnershipKind() const;
void setOwnershipKind(ValueOwnershipKind newKind) const;
void replaceOwnershipKind(ValueOwnershipKind oldKind,
ValueOwnershipKind newKind) const;
const OwnershipForwardingInst *operator->() const {
return cast<OwnershipForwardingInst>(use->getUser());
}
OwnershipForwardingInst *operator->() {
return cast<OwnershipForwardingInst>(use->getUser());
}
const OwnershipForwardingInst &operator*() const {
return *cast<OwnershipForwardingInst>(use->getUser());
}
OwnershipForwardingInst &operator*() {
return *cast<OwnershipForwardingInst>(use->getUser());
}
const Operand *operator->() const { return use; }
Operand *operator->() { return use; }
const Operand &operator*() const { return *use; }
Operand &operator*() { return *use; }
/// Call \p visitor with each value that contains the final forwarded
/// ownership of. E.x.: result of a unchecked_ref_cast, phi arguments of a