forked from OSchip/llvm-project
Add support for Operation::moveBefore(Operation *).
PiperOrigin-RevId: 222252521
This commit is contained in:
parent
89d9913a20
commit
d63ab4b47a
|
@ -120,6 +120,11 @@ public:
|
|||
/// Return true if there are no users of any results of this operation.
|
||||
bool use_empty() const;
|
||||
|
||||
/// Unlink this operation from its current block and insert it right before
|
||||
/// `existingOp` which may be in the same or another block of the same
|
||||
/// function.
|
||||
void moveBefore(Operation *existingOp);
|
||||
|
||||
// Attributes. Operations may optionally carry a list of attributes that
|
||||
// associate constants to names. Attributes may be dynamically added and
|
||||
// removed over the lifetime of an operation.
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
using Statement::emitNote;
|
||||
using Statement::emitWarning;
|
||||
using Statement::getLoc;
|
||||
using Statement::moveBefore;
|
||||
using Statement::print;
|
||||
|
||||
/// Check if this statement is a return statement.
|
||||
|
|
|
@ -197,6 +197,13 @@ bool Operation::use_empty() const {
|
|||
return true;
|
||||
}
|
||||
|
||||
void Operation::moveBefore(Operation *existingOp) {
|
||||
if (auto *inst = llvm::dyn_cast<Instruction>(this))
|
||||
return inst->moveBefore(llvm::cast<Instruction>(existingOp));
|
||||
return llvm::cast<OperationStmt>(this)->moveBefore(
|
||||
llvm::cast<OperationStmt>(existingOp));
|
||||
}
|
||||
|
||||
ArrayRef<NamedAttribute> Operation::getAttrs() const {
|
||||
if (!attrs)
|
||||
return {};
|
||||
|
|
Loading…
Reference in New Issue