//===- Value.cpp - MLIR Value Classes -------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #include "mlir/IR/Value.h" #include "mlir/IR/Block.h" #include "mlir/IR/BuiltinTypes.h" #include "mlir/IR/Operation.h" #include "llvm/ADT/SmallPtrSet.h" usingnamespacemlir; usingnamespacemlir::detail; /// If this value is the result of an Operation, return the operation that /// defines it. Operation *Value::getDefiningOp() const { … } Location Value::getLoc() const { … } void Value::setLoc(Location loc) { … } /// Return the Region in which this Value is defined. Region *Value::getParentRegion() { … } /// Return the Block in which this Value is defined. Block *Value::getParentBlock() { … } //===----------------------------------------------------------------------===// // Value::UseLists //===----------------------------------------------------------------------===// /// Replace all uses of 'this' value with the new value, updating anything in /// the IR that uses 'this' to use the other value instead except if the user is /// listed in 'exceptions' . void Value::replaceAllUsesExcept( Value newValue, const SmallPtrSetImpl<Operation *> &exceptions) { … } /// Replace all uses of 'this' value with 'newValue', updating anything in the /// IR that uses 'this' to use the other value instead except if the user is /// 'exceptedUser'. void Value::replaceAllUsesExcept(Value newValue, Operation *exceptedUser) { … } /// Replace all uses of 'this' value with 'newValue' if the given callback /// returns true. void Value::replaceUsesWithIf(Value newValue, function_ref<bool(OpOperand &)> shouldReplace) { … } /// Returns true if the value is used outside of the given block. bool Value::isUsedOutsideOfBlock(Block *block) const { … } /// Shuffles the use-list order according to the provided indices. void Value::shuffleUseList(ArrayRef<unsigned> indices) { … } //===----------------------------------------------------------------------===// // OpResult //===----------------------------------------------------------------------===// /// Returns the parent operation of this trailing result. Operation *OpResultImpl::getOwner() const { … } OpResultImpl *OpResultImpl::getNextResultAtOffset(intptr_t offset) { … } /// Given a number of operation results, returns the number that need to be /// stored inline. unsigned OpResult::getNumInline(unsigned numResults) { … } /// Given a number of operation results, returns the number that need to be /// stored as trailing. unsigned OpResult::getNumTrailing(unsigned numResults) { … } //===----------------------------------------------------------------------===// // BlockOperand //===----------------------------------------------------------------------===// /// Provide the use list that is attached to the given block. IRObjectWithUseList<BlockOperand> *BlockOperand::getUseList(Block *value) { … } /// Return which operand this is in the operand list. unsigned BlockOperand::getOperandNumber() { … } //===----------------------------------------------------------------------===// // OpOperand //===----------------------------------------------------------------------===// /// Return which operand this is in the operand list. unsigned OpOperand::getOperandNumber() { … }