mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
Rename BBArgument -> BlockArgument, Op::getOperation -> Op::getInst(),
StmtResult -> InstResult, StmtOperand -> InstOperand, and remove the old names. This is step 17/n towards merging instructions and statements, NFC. PiperOrigin-RevId: 227121537
This commit is contained in:
@@ -66,12 +66,12 @@ public:
|
||||
|
||||
OpType *operator->() { return &value; }
|
||||
|
||||
operator bool() const { return value.getOperation(); }
|
||||
operator bool() const { return value.getInstruction(); }
|
||||
|
||||
/// OpPointer can be implicitly converted to OpType*.
|
||||
/// Return `nullptr` if there is no associated OperationInst*.
|
||||
operator OpType *() {
|
||||
if (!value.getOperation())
|
||||
if (!value.getInstruction())
|
||||
return nullptr;
|
||||
return &value;
|
||||
}
|
||||
@@ -102,12 +102,12 @@ public:
|
||||
const OpType *operator->() const { return &value; }
|
||||
|
||||
/// Return true if non-null.
|
||||
operator bool() const { return value.getOperation(); }
|
||||
operator bool() const { return value.getInstruction(); }
|
||||
|
||||
/// ConstOpPointer can always be implicitly converted to const OpType*.
|
||||
/// Return `nullptr` if there is no associated OperationInst*.
|
||||
operator const OpType *() const {
|
||||
if (!value.getOperation())
|
||||
if (!value.getInstruction())
|
||||
return nullptr;
|
||||
return &value;
|
||||
}
|
||||
@@ -137,8 +137,8 @@ private:
|
||||
class OpState {
|
||||
public:
|
||||
/// Return the operation that this refers to.
|
||||
const OperationInst *getOperation() const { return state; }
|
||||
OperationInst *getOperation() { return state; }
|
||||
const OperationInst *getInstruction() const { return state; }
|
||||
OperationInst *getInstruction() { return state; }
|
||||
|
||||
/// The source location the operation was defined or derived from.
|
||||
Location getLoc() const { return state->getLoc(); }
|
||||
@@ -303,7 +303,7 @@ template <typename ConcreteType, template <typename> class TraitType>
|
||||
class TraitBase {
|
||||
protected:
|
||||
/// Return the ultimate OperationInst being worked on.
|
||||
OperationInst *getOperation() {
|
||||
OperationInst *getInstruction() {
|
||||
// We have to cast up to the trait type, then to the concrete type, then to
|
||||
// the BaseState class in explicit hops because the concrete type will
|
||||
// multiply derive from the (content free) TraitBase class, and we need to
|
||||
@@ -311,10 +311,10 @@ protected:
|
||||
auto *trait = static_cast<TraitType<ConcreteType> *>(this);
|
||||
auto *concrete = static_cast<ConcreteType *>(trait);
|
||||
auto *base = static_cast<OpState *>(concrete);
|
||||
return base->getOperation();
|
||||
return base->getInstruction();
|
||||
}
|
||||
const OperationInst *getOperation() const {
|
||||
return const_cast<TraitBase *>(this)->getOperation();
|
||||
const OperationInst *getInstruction() const {
|
||||
return const_cast<TraitBase *>(this)->getInstruction();
|
||||
}
|
||||
|
||||
/// Provide default implementations of trait hooks. This allows traits to
|
||||
@@ -346,12 +346,14 @@ template <typename ConcreteType>
|
||||
class OneOperand : public TraitBase<ConcreteType, OneOperand> {
|
||||
public:
|
||||
const Value *getOperand() const {
|
||||
return this->getOperation()->getOperand(0);
|
||||
return this->getInstruction()->getOperand(0);
|
||||
}
|
||||
|
||||
Value *getOperand() { return this->getOperation()->getOperand(0); }
|
||||
Value *getOperand() { return this->getInstruction()->getOperand(0); }
|
||||
|
||||
void setOperand(Value *value) { this->getOperation()->setOperand(0, value); }
|
||||
void setOperand(Value *value) {
|
||||
this->getInstruction()->setOperand(0, value);
|
||||
}
|
||||
|
||||
static bool verifyTrait(const OperationInst *op) {
|
||||
return impl::verifyOneOperand(op);
|
||||
@@ -369,15 +371,15 @@ public:
|
||||
class Impl : public TraitBase<ConcreteType, NOperands<N>::Impl> {
|
||||
public:
|
||||
const Value *getOperand(unsigned i) const {
|
||||
return this->getOperation()->getOperand(i);
|
||||
return this->getInstruction()->getOperand(i);
|
||||
}
|
||||
|
||||
Value *getOperand(unsigned i) {
|
||||
return this->getOperation()->getOperand(i);
|
||||
return this->getInstruction()->getOperand(i);
|
||||
}
|
||||
|
||||
void setOperand(unsigned i, Value *value) {
|
||||
this->getOperation()->setOperand(i, value);
|
||||
this->getInstruction()->setOperand(i, value);
|
||||
}
|
||||
|
||||
static bool verifyTrait(const OperationInst *op) {
|
||||
@@ -397,42 +399,42 @@ public:
|
||||
class Impl : public TraitBase<ConcreteType, AtLeastNOperands<N>::Impl> {
|
||||
public:
|
||||
unsigned getNumOperands() const {
|
||||
return this->getOperation()->getNumOperands();
|
||||
return this->getInstruction()->getNumOperands();
|
||||
}
|
||||
const Value *getOperand(unsigned i) const {
|
||||
return this->getOperation()->getOperand(i);
|
||||
return this->getInstruction()->getOperand(i);
|
||||
}
|
||||
|
||||
Value *getOperand(unsigned i) {
|
||||
return this->getOperation()->getOperand(i);
|
||||
return this->getInstruction()->getOperand(i);
|
||||
}
|
||||
|
||||
void setOperand(unsigned i, Value *value) {
|
||||
this->getOperation()->setOperand(i, value);
|
||||
this->getInstruction()->setOperand(i, value);
|
||||
}
|
||||
|
||||
// Support non-const operand iteration.
|
||||
using operand_iterator = OperationInst::operand_iterator;
|
||||
operand_iterator operand_begin() {
|
||||
return this->getOperation()->operand_begin();
|
||||
return this->getInstruction()->operand_begin();
|
||||
}
|
||||
operand_iterator operand_end() {
|
||||
return this->getOperation()->operand_end();
|
||||
return this->getInstruction()->operand_end();
|
||||
}
|
||||
llvm::iterator_range<operand_iterator> getOperands() {
|
||||
return this->getOperation()->getOperands();
|
||||
return this->getInstruction()->getOperands();
|
||||
}
|
||||
|
||||
// Support const operand iteration.
|
||||
using const_operand_iterator = OperationInst::const_operand_iterator;
|
||||
const_operand_iterator operand_begin() const {
|
||||
return this->getOperation()->operand_begin();
|
||||
return this->getInstruction()->operand_begin();
|
||||
}
|
||||
const_operand_iterator operand_end() const {
|
||||
return this->getOperation()->operand_end();
|
||||
return this->getInstruction()->operand_end();
|
||||
}
|
||||
llvm::iterator_range<const_operand_iterator> getOperands() const {
|
||||
return this->getOperation()->getOperands();
|
||||
return this->getInstruction()->getOperands();
|
||||
}
|
||||
|
||||
static bool verifyTrait(const OperationInst *op) {
|
||||
@@ -447,39 +449,43 @@ template <typename ConcreteType>
|
||||
class VariadicOperands : public TraitBase<ConcreteType, VariadicOperands> {
|
||||
public:
|
||||
unsigned getNumOperands() const {
|
||||
return this->getOperation()->getNumOperands();
|
||||
return this->getInstruction()->getNumOperands();
|
||||
}
|
||||
|
||||
const Value *getOperand(unsigned i) const {
|
||||
return this->getOperation()->getOperand(i);
|
||||
return this->getInstruction()->getOperand(i);
|
||||
}
|
||||
|
||||
Value *getOperand(unsigned i) { return this->getOperation()->getOperand(i); }
|
||||
Value *getOperand(unsigned i) {
|
||||
return this->getInstruction()->getOperand(i);
|
||||
}
|
||||
|
||||
void setOperand(unsigned i, Value *value) {
|
||||
this->getOperation()->setOperand(i, value);
|
||||
this->getInstruction()->setOperand(i, value);
|
||||
}
|
||||
|
||||
// Support non-const operand iteration.
|
||||
using operand_iterator = OperationInst::operand_iterator;
|
||||
operand_iterator operand_begin() {
|
||||
return this->getOperation()->operand_begin();
|
||||
return this->getInstruction()->operand_begin();
|
||||
}
|
||||
operand_iterator operand_end() {
|
||||
return this->getInstruction()->operand_end();
|
||||
}
|
||||
operand_iterator operand_end() { return this->getOperation()->operand_end(); }
|
||||
llvm::iterator_range<operand_iterator> getOperands() {
|
||||
return this->getOperation()->getOperands();
|
||||
return this->getInstruction()->getOperands();
|
||||
}
|
||||
|
||||
// Support const operand iteration.
|
||||
using const_operand_iterator = OperationInst::const_operand_iterator;
|
||||
const_operand_iterator operand_begin() const {
|
||||
return this->getOperation()->operand_begin();
|
||||
return this->getInstruction()->operand_begin();
|
||||
}
|
||||
const_operand_iterator operand_end() const {
|
||||
return this->getOperation()->operand_end();
|
||||
return this->getInstruction()->operand_end();
|
||||
}
|
||||
llvm::iterator_range<const_operand_iterator> getOperands() const {
|
||||
return this->getOperation()->getOperands();
|
||||
return this->getInstruction()->getOperands();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -498,8 +504,10 @@ public:
|
||||
template <typename ConcreteType>
|
||||
class OneResult : public TraitBase<ConcreteType, OneResult> {
|
||||
public:
|
||||
Value *getResult() { return this->getOperation()->getResult(0); }
|
||||
const Value *getResult() const { return this->getOperation()->getResult(0); }
|
||||
Value *getResult() { return this->getInstruction()->getResult(0); }
|
||||
const Value *getResult() const {
|
||||
return this->getInstruction()->getResult(0);
|
||||
}
|
||||
|
||||
Type getType() const { return getResult()->getType(); }
|
||||
|
||||
@@ -542,10 +550,12 @@ public:
|
||||
static unsigned getNumResults() { return N; }
|
||||
|
||||
const Value *getResult(unsigned i) const {
|
||||
return this->getOperation()->getResult(i);
|
||||
return this->getInstruction()->getResult(i);
|
||||
}
|
||||
|
||||
Value *getResult(unsigned i) { return this->getOperation()->getResult(i); }
|
||||
Value *getResult(unsigned i) {
|
||||
return this->getInstruction()->getResult(i);
|
||||
}
|
||||
|
||||
Type getType(unsigned i) const { return getResult(i)->getType(); }
|
||||
|
||||
@@ -566,10 +576,12 @@ public:
|
||||
class Impl : public TraitBase<ConcreteType, AtLeastNResults<N>::Impl> {
|
||||
public:
|
||||
const Value *getResult(unsigned i) const {
|
||||
return this->getOperation()->getResult(i);
|
||||
return this->getInstruction()->getResult(i);
|
||||
}
|
||||
|
||||
Value *getResult(unsigned i) { return this->getOperation()->getResult(i); }
|
||||
Value *getResult(unsigned i) {
|
||||
return this->getInstruction()->getResult(i);
|
||||
}
|
||||
|
||||
Type getType(unsigned i) const { return getResult(i)->getType(); }
|
||||
|
||||
@@ -585,39 +597,39 @@ template <typename ConcreteType>
|
||||
class VariadicResults : public TraitBase<ConcreteType, VariadicResults> {
|
||||
public:
|
||||
unsigned getNumResults() const {
|
||||
return this->getOperation()->getNumResults();
|
||||
return this->getInstruction()->getNumResults();
|
||||
}
|
||||
|
||||
const Value *getResult(unsigned i) const {
|
||||
return this->getOperation()->getResult(i);
|
||||
return this->getInstruction()->getResult(i);
|
||||
}
|
||||
|
||||
Value *getResult(unsigned i) { return this->getOperation()->getResult(i); }
|
||||
Value *getResult(unsigned i) { return this->getInstruction()->getResult(i); }
|
||||
|
||||
void setResult(unsigned i, Value *value) {
|
||||
this->getOperation()->setResult(i, value);
|
||||
this->getInstruction()->setResult(i, value);
|
||||
}
|
||||
|
||||
// Support non-const result iteration.
|
||||
using result_iterator = OperationInst::result_iterator;
|
||||
result_iterator result_begin() {
|
||||
return this->getOperation()->result_begin();
|
||||
return this->getInstruction()->result_begin();
|
||||
}
|
||||
result_iterator result_end() { return this->getOperation()->result_end(); }
|
||||
result_iterator result_end() { return this->getInstruction()->result_end(); }
|
||||
llvm::iterator_range<result_iterator> getResults() {
|
||||
return this->getOperation()->getResults();
|
||||
return this->getInstruction()->getResults();
|
||||
}
|
||||
|
||||
// Support const result iteration.
|
||||
using const_result_iterator = OperationInst::const_result_iterator;
|
||||
const_result_iterator result_begin() const {
|
||||
return this->getOperation()->result_begin();
|
||||
return this->getInstruction()->result_begin();
|
||||
}
|
||||
const_result_iterator result_end() const {
|
||||
return this->getOperation()->result_end();
|
||||
return this->getInstruction()->result_end();
|
||||
}
|
||||
llvm::iterator_range<const_result_iterator> getResults() const {
|
||||
return this->getOperation()->getResults();
|
||||
return this->getInstruction()->getResults();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -734,28 +746,28 @@ public:
|
||||
}
|
||||
|
||||
unsigned getNumSuccessors() const {
|
||||
return this->getOperation()->getNumSuccessors();
|
||||
return this->getInstruction()->getNumSuccessors();
|
||||
}
|
||||
unsigned getNumSuccessorOperands(unsigned index) const {
|
||||
return this->getOperation()->getNumSuccessorOperands(index);
|
||||
return this->getInstruction()->getNumSuccessorOperands(index);
|
||||
}
|
||||
|
||||
const BasicBlock *getSuccessor(unsigned index) const {
|
||||
return this->getOperation()->getSuccessor(index);
|
||||
return this->getInstruction()->getSuccessor(index);
|
||||
}
|
||||
BasicBlock *getSuccessor(unsigned index) {
|
||||
return this->getOperation()->getSuccessor(index);
|
||||
return this->getInstruction()->getSuccessor(index);
|
||||
}
|
||||
|
||||
void setSuccessor(BasicBlock *block, unsigned index) {
|
||||
return this->getOperation()->setSuccessor(block, index);
|
||||
return this->getInstruction()->setSuccessor(block, index);
|
||||
}
|
||||
|
||||
void addSuccessorOperand(unsigned index, Value *value) {
|
||||
return this->getOperation()->addSuccessorOperand(index, value);
|
||||
return this->getInstruction()->addSuccessorOperand(index, value);
|
||||
}
|
||||
void addSuccessorOperands(unsigned index, ArrayRef<Value *> values) {
|
||||
return this->getOperation()->addSuccessorOperand(index, values);
|
||||
return this->getInstruction()->addSuccessorOperand(index, values);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -777,8 +789,10 @@ class Op : public OpState,
|
||||
Traits<ConcreteType>...>::value> {
|
||||
public:
|
||||
/// Return the operation that this refers to.
|
||||
const OperationInst *getOperation() const { return OpState::getOperation(); }
|
||||
OperationInst *getOperation() { return OpState::getOperation(); }
|
||||
const OperationInst *getInstruction() const {
|
||||
return OpState::getInstruction();
|
||||
}
|
||||
OperationInst *getInstruction() { return OpState::getInstruction(); }
|
||||
|
||||
/// Return true if this "op class" can match against the specified operation.
|
||||
/// This hook can be overridden with a more specific implementation in
|
||||
@@ -903,7 +917,7 @@ public:
|
||||
return impl::parseBinaryOp(parser, result);
|
||||
}
|
||||
void print(OpAsmPrinter *p) const {
|
||||
return impl::printBinaryOp(this->getOperation(), p);
|
||||
return impl::printBinaryOp(this->getInstruction(), p);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -939,7 +953,7 @@ public:
|
||||
return impl::parseCastOp(parser, result);
|
||||
}
|
||||
void print(OpAsmPrinter *p) const {
|
||||
return impl::printCastOp(this->getOperation(), p);
|
||||
return impl::printCastOp(this->getInstruction(), p);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
template <typename OpTy, typename... Args>
|
||||
void replaceOpWithNewOp(OperationInst *op, Args... args) {
|
||||
auto newOp = create<OpTy>(op->getLoc(), args...);
|
||||
replaceOpWithResultsOfAnotherOp(op, newOp->getOperation(), {});
|
||||
replaceOpWithResultsOfAnotherOp(op, newOp->getInstruction(), {});
|
||||
}
|
||||
|
||||
/// Replaces the result op with a new op that is created without verification.
|
||||
@@ -241,7 +241,7 @@ public:
|
||||
ArrayRef<Value *> valuesToRemoveIfDead,
|
||||
Args... args) {
|
||||
auto newOp = create<OpTy>(op->getLoc(), args...);
|
||||
replaceOpWithResultsOfAnotherOp(op, newOp->getOperation(),
|
||||
replaceOpWithResultsOfAnotherOp(op, newOp->getInstruction(),
|
||||
valuesToRemoveIfDead);
|
||||
}
|
||||
|
||||
|
||||
@@ -160,14 +160,14 @@ public:
|
||||
/// Returns a const iterator on the underlying Values.
|
||||
llvm::iterator_range<const_operand_iterator> getOperands() const;
|
||||
|
||||
MutableArrayRef<StmtOperand> getStmtOperands();
|
||||
ArrayRef<StmtOperand> getStmtOperands() const {
|
||||
return const_cast<Statement *>(this)->getStmtOperands();
|
||||
MutableArrayRef<InstOperand> getInstOperands();
|
||||
ArrayRef<InstOperand> getInstOperands() const {
|
||||
return const_cast<Statement *>(this)->getInstOperands();
|
||||
}
|
||||
|
||||
StmtOperand &getStmtOperand(unsigned idx) { return getStmtOperands()[idx]; }
|
||||
const StmtOperand &getStmtOperand(unsigned idx) const {
|
||||
return getStmtOperands()[idx];
|
||||
InstOperand &getInstOperand(unsigned idx) { return getInstOperands()[idx]; }
|
||||
const InstOperand &getInstOperand(unsigned idx) const {
|
||||
return getInstOperands()[idx];
|
||||
}
|
||||
|
||||
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||
|
||||
@@ -46,8 +46,8 @@ class Function;
|
||||
///
|
||||
class OperationInst final
|
||||
: public Statement,
|
||||
private llvm::TrailingObjects<OperationInst, StmtResult, StmtBlockOperand,
|
||||
unsigned, StmtOperand> {
|
||||
private llvm::TrailingObjects<OperationInst, InstResult, StmtBlockOperand,
|
||||
unsigned, InstOperand> {
|
||||
public:
|
||||
/// Create a new OperationInst with the specific fields.
|
||||
static OperationInst *
|
||||
@@ -76,12 +76,12 @@ public:
|
||||
|
||||
unsigned getNumOperands() const { return numOperands; }
|
||||
|
||||
Value *getOperand(unsigned idx) { return getStmtOperand(idx).get(); }
|
||||
Value *getOperand(unsigned idx) { return getInstOperand(idx).get(); }
|
||||
const Value *getOperand(unsigned idx) const {
|
||||
return getStmtOperand(idx).get();
|
||||
return getInstOperand(idx).get();
|
||||
}
|
||||
void setOperand(unsigned idx, Value *value) {
|
||||
return getStmtOperand(idx).set(value);
|
||||
return getInstOperand(idx).set(value);
|
||||
}
|
||||
|
||||
// Support non-const operand iteration.
|
||||
@@ -115,16 +115,16 @@ public:
|
||||
return {operand_begin(), operand_end()};
|
||||
}
|
||||
|
||||
ArrayRef<StmtOperand> getStmtOperands() const {
|
||||
return {getTrailingObjects<StmtOperand>(), numOperands};
|
||||
ArrayRef<InstOperand> getInstOperands() const {
|
||||
return {getTrailingObjects<InstOperand>(), numOperands};
|
||||
}
|
||||
MutableArrayRef<StmtOperand> getStmtOperands() {
|
||||
return {getTrailingObjects<StmtOperand>(), numOperands};
|
||||
MutableArrayRef<InstOperand> getInstOperands() {
|
||||
return {getTrailingObjects<InstOperand>(), numOperands};
|
||||
}
|
||||
|
||||
StmtOperand &getStmtOperand(unsigned idx) { return getStmtOperands()[idx]; }
|
||||
const StmtOperand &getStmtOperand(unsigned idx) const {
|
||||
return getStmtOperands()[idx];
|
||||
InstOperand &getInstOperand(unsigned idx) { return getInstOperands()[idx]; }
|
||||
const InstOperand &getInstOperand(unsigned idx) const {
|
||||
return getInstOperands()[idx];
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
@@ -136,8 +136,8 @@ public:
|
||||
|
||||
unsigned getNumResults() const { return numResults; }
|
||||
|
||||
Value *getResult(unsigned idx) { return &getStmtResult(idx); }
|
||||
const Value *getResult(unsigned idx) const { return &getStmtResult(idx); }
|
||||
Value *getResult(unsigned idx) { return &getInstResult(idx); }
|
||||
const Value *getResult(unsigned idx) const { return &getInstResult(idx); }
|
||||
|
||||
// Support non-const result iteration.
|
||||
using result_iterator = ResultIterator<OperationInst, Value>;
|
||||
@@ -154,18 +154,18 @@ public:
|
||||
|
||||
llvm::iterator_range<const_result_iterator> getResults() const;
|
||||
|
||||
ArrayRef<StmtResult> getStmtResults() const {
|
||||
return {getTrailingObjects<StmtResult>(), numResults};
|
||||
ArrayRef<InstResult> getInstResults() const {
|
||||
return {getTrailingObjects<InstResult>(), numResults};
|
||||
}
|
||||
|
||||
MutableArrayRef<StmtResult> getStmtResults() {
|
||||
return {getTrailingObjects<StmtResult>(), numResults};
|
||||
MutableArrayRef<InstResult> getInstResults() {
|
||||
return {getTrailingObjects<InstResult>(), numResults};
|
||||
}
|
||||
|
||||
StmtResult &getStmtResult(unsigned idx) { return getStmtResults()[idx]; }
|
||||
InstResult &getInstResult(unsigned idx) { return getInstResults()[idx]; }
|
||||
|
||||
const StmtResult &getStmtResult(unsigned idx) const {
|
||||
return getStmtResults()[idx];
|
||||
const InstResult &getInstResult(unsigned idx) const {
|
||||
return getInstResults()[idx];
|
||||
}
|
||||
|
||||
// Support result type iteration.
|
||||
@@ -404,12 +404,12 @@ private:
|
||||
void eraseOperand(unsigned index);
|
||||
|
||||
// This stuff is used by the TrailingObjects template.
|
||||
friend llvm::TrailingObjects<OperationInst, StmtResult, StmtBlockOperand,
|
||||
unsigned, StmtOperand>;
|
||||
size_t numTrailingObjects(OverloadToken<StmtOperand>) const {
|
||||
friend llvm::TrailingObjects<OperationInst, InstResult, StmtBlockOperand,
|
||||
unsigned, InstOperand>;
|
||||
size_t numTrailingObjects(OverloadToken<InstOperand>) const {
|
||||
return numOperands;
|
||||
}
|
||||
size_t numTrailingObjects(OverloadToken<StmtResult>) const {
|
||||
size_t numTrailingObjects(OverloadToken<InstResult>) const {
|
||||
return numResults;
|
||||
}
|
||||
size_t numTrailingObjects(OverloadToken<StmtBlockOperand>) const {
|
||||
@@ -603,12 +603,12 @@ public:
|
||||
|
||||
unsigned getNumOperands() const { return operands.size(); }
|
||||
|
||||
Value *getOperand(unsigned idx) { return getStmtOperand(idx).get(); }
|
||||
Value *getOperand(unsigned idx) { return getInstOperand(idx).get(); }
|
||||
const Value *getOperand(unsigned idx) const {
|
||||
return getStmtOperand(idx).get();
|
||||
return getInstOperand(idx).get();
|
||||
}
|
||||
void setOperand(unsigned idx, Value *value) {
|
||||
getStmtOperand(idx).set(value);
|
||||
getInstOperand(idx).set(value);
|
||||
}
|
||||
|
||||
operand_iterator operand_begin() { return operand_iterator(this, 0); }
|
||||
@@ -623,11 +623,11 @@ public:
|
||||
return const_operand_iterator(this, getNumOperands());
|
||||
}
|
||||
|
||||
ArrayRef<StmtOperand> getStmtOperands() const { return operands; }
|
||||
MutableArrayRef<StmtOperand> getStmtOperands() { return operands; }
|
||||
StmtOperand &getStmtOperand(unsigned idx) { return getStmtOperands()[idx]; }
|
||||
const StmtOperand &getStmtOperand(unsigned idx) const {
|
||||
return getStmtOperands()[idx];
|
||||
ArrayRef<InstOperand> getInstOperands() const { return operands; }
|
||||
MutableArrayRef<InstOperand> getInstOperands() { return operands; }
|
||||
InstOperand &getInstOperand(unsigned idx) { return getInstOperands()[idx]; }
|
||||
const InstOperand &getInstOperand(unsigned idx) const {
|
||||
return getInstOperands()[idx];
|
||||
}
|
||||
|
||||
// TODO: provide iterators for the lower and upper bound operands
|
||||
@@ -677,7 +677,7 @@ private:
|
||||
// Operands for the lower and upper bounds, with the former followed by the
|
||||
// latter. Dimensional operands are followed by symbolic operands for each
|
||||
// bound.
|
||||
std::vector<StmtOperand> operands;
|
||||
std::vector<InstOperand> operands;
|
||||
|
||||
explicit ForStmt(Location location, unsigned numOperands, AffineMap lbMap,
|
||||
AffineMap ubMap, int64_t step);
|
||||
@@ -696,8 +696,8 @@ public:
|
||||
const Value *getOperand(unsigned idx) const {
|
||||
return stmt.getOperand(opStart + idx);
|
||||
}
|
||||
const StmtOperand &getStmtOperand(unsigned idx) const {
|
||||
return stmt.getStmtOperand(opStart + idx);
|
||||
const InstOperand &getInstOperand(unsigned idx) const {
|
||||
return stmt.getInstOperand(opStart + idx);
|
||||
}
|
||||
|
||||
using operand_iterator = ForStmt::operand_iterator;
|
||||
@@ -714,9 +714,9 @@ public:
|
||||
|
||||
/// Returns an iterator on the underlying Value's (Value *).
|
||||
operand_range getOperands() const { return {operand_begin(), operand_end()}; }
|
||||
ArrayRef<StmtOperand> getStmtOperands() const {
|
||||
auto ops = stmt.getStmtOperands();
|
||||
return ArrayRef<StmtOperand>(ops.begin() + opStart, ops.begin() + opEnd);
|
||||
ArrayRef<InstOperand> getInstOperands() const {
|
||||
auto ops = stmt.getInstOperands();
|
||||
return ArrayRef<InstOperand>(ops.begin() + opStart, ops.begin() + opEnd);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -783,12 +783,12 @@ public:
|
||||
|
||||
unsigned getNumOperands() const { return operands.size(); }
|
||||
|
||||
Value *getOperand(unsigned idx) { return getStmtOperand(idx).get(); }
|
||||
Value *getOperand(unsigned idx) { return getInstOperand(idx).get(); }
|
||||
const Value *getOperand(unsigned idx) const {
|
||||
return getStmtOperand(idx).get();
|
||||
return getInstOperand(idx).get();
|
||||
}
|
||||
void setOperand(unsigned idx, Value *value) {
|
||||
getStmtOperand(idx).set(value);
|
||||
getInstOperand(idx).set(value);
|
||||
}
|
||||
|
||||
operand_iterator operand_begin() { return operand_iterator(this, 0); }
|
||||
@@ -803,11 +803,11 @@ public:
|
||||
return const_operand_iterator(this, getNumOperands());
|
||||
}
|
||||
|
||||
ArrayRef<StmtOperand> getStmtOperands() const { return operands; }
|
||||
MutableArrayRef<StmtOperand> getStmtOperands() { return operands; }
|
||||
StmtOperand &getStmtOperand(unsigned idx) { return getStmtOperands()[idx]; }
|
||||
const StmtOperand &getStmtOperand(unsigned idx) const {
|
||||
return getStmtOperands()[idx];
|
||||
ArrayRef<InstOperand> getInstOperands() const { return operands; }
|
||||
MutableArrayRef<InstOperand> getInstOperands() { return operands; }
|
||||
InstOperand &getInstOperand(unsigned idx) { return getInstOperands()[idx]; }
|
||||
const InstOperand &getInstOperand(unsigned idx) const {
|
||||
return getInstOperands()[idx];
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
@@ -831,7 +831,7 @@ private:
|
||||
IntegerSet set;
|
||||
|
||||
// Condition operands.
|
||||
std::vector<StmtOperand> operands;
|
||||
std::vector<InstOperand> operands;
|
||||
|
||||
explicit IfStmt(Location location, unsigned numOperands, IntegerSet set);
|
||||
};
|
||||
|
||||
@@ -128,7 +128,7 @@ public:
|
||||
}
|
||||
|
||||
/// Return the owner of this operand, for example, the OperationInst that
|
||||
/// contains a StmtOperand.
|
||||
/// contains an InstOperand.
|
||||
IROperandOwner *getOwner() { return owner; }
|
||||
const IROperandOwner *getOwner() const { return owner; }
|
||||
|
||||
@@ -175,8 +175,8 @@ private:
|
||||
/// This points to the previous link in the use-chain.
|
||||
IROperand **back = nullptr;
|
||||
|
||||
/// The owner of this operand, for example, the OperationInst that contains a
|
||||
/// StmtOperand.
|
||||
/// The owner of this operand, for example, the OperationInst that contains an
|
||||
/// InstOperand.
|
||||
IROperandOwner *const owner;
|
||||
|
||||
/// Operands are not copyable or assignable.
|
||||
|
||||
@@ -33,10 +33,9 @@ class Statement;
|
||||
class StmtBlock;
|
||||
class Value;
|
||||
using Instruction = Statement;
|
||||
using OperationInst = OperationInst;
|
||||
|
||||
/// Operands contain a Value.
|
||||
using StmtOperand = IROperandImpl<Value, Statement>;
|
||||
using InstOperand = IROperandImpl<Value, Statement>;
|
||||
|
||||
/// This is the common base class for all SSA values in the MLIR system,
|
||||
/// representing a computable value that has a type and a set of users.
|
||||
@@ -46,7 +45,7 @@ public:
|
||||
/// This enumerates all of the SSA value kinds in the MLIR system.
|
||||
enum class Kind {
|
||||
BlockArgument, // block argument
|
||||
StmtResult, // statement result
|
||||
InstResult, // operation instruction result
|
||||
ForStmt, // 'for' statement induction variable
|
||||
};
|
||||
|
||||
@@ -87,7 +86,7 @@ public:
|
||||
return const_cast<Value *>(this)->getDefiningInst();
|
||||
}
|
||||
|
||||
using use_iterator = ValueUseIterator<StmtOperand, Statement>;
|
||||
using use_iterator = ValueUseIterator<InstOperand, Statement>;
|
||||
using use_range = llvm::iterator_range<use_iterator>;
|
||||
|
||||
inline use_iterator use_begin() const;
|
||||
@@ -113,7 +112,7 @@ inline raw_ostream &operator<<(raw_ostream &os, const Value &value) {
|
||||
|
||||
// Utility functions for iterating through Value uses.
|
||||
inline auto Value::use_begin() const -> use_iterator {
|
||||
return use_iterator((StmtOperand *)getFirstUse());
|
||||
return use_iterator((InstOperand *)getFirstUse());
|
||||
}
|
||||
|
||||
inline auto Value::use_end() const -> use_iterator {
|
||||
@@ -152,13 +151,13 @@ private:
|
||||
};
|
||||
|
||||
/// This is a value defined by a result of an operation instruction.
|
||||
class StmtResult : public Value {
|
||||
class InstResult : public Value {
|
||||
public:
|
||||
StmtResult(Type type, OperationInst *owner)
|
||||
: Value(Value::Kind::StmtResult, type), owner(owner) {}
|
||||
InstResult(Type type, OperationInst *owner)
|
||||
: Value(Value::Kind::InstResult, type), owner(owner) {}
|
||||
|
||||
static bool classof(const Value *value) {
|
||||
return value->getKind() == Kind::StmtResult;
|
||||
return value->getKind() == Kind::InstResult;
|
||||
}
|
||||
|
||||
OperationInst *getOwner() { return owner; }
|
||||
@@ -174,10 +173,6 @@ private:
|
||||
OperationInst *const owner;
|
||||
};
|
||||
|
||||
// TODO(clattner) clean all this up.
|
||||
using BBArgument = BlockArgument;
|
||||
using InstResult = StmtResult;
|
||||
|
||||
} // namespace mlir
|
||||
|
||||
#endif
|
||||
|
||||
@@ -369,8 +369,8 @@ public:
|
||||
// Returns the source memerf indices for this DMA operation.
|
||||
llvm::iterator_range<OperationInst::const_operand_iterator>
|
||||
getSrcIndices() const {
|
||||
return {getOperation()->operand_begin() + 1,
|
||||
getOperation()->operand_begin() + 1 + getSrcMemRefRank()};
|
||||
return {getInstruction()->operand_begin() + 1,
|
||||
getInstruction()->operand_begin() + 1 + getSrcMemRefRank()};
|
||||
}
|
||||
|
||||
// Returns the destination MemRefType for this DMA operations.
|
||||
@@ -391,8 +391,8 @@ public:
|
||||
// Returns the destination memref indices for this DMA operation.
|
||||
llvm::iterator_range<OperationInst::const_operand_iterator>
|
||||
getDstIndices() const {
|
||||
return {getOperation()->operand_begin() + 1 + getSrcMemRefRank() + 1,
|
||||
getOperation()->operand_begin() + 1 + getSrcMemRefRank() + 1 +
|
||||
return {getInstruction()->operand_begin() + 1 + getSrcMemRefRank() + 1,
|
||||
getInstruction()->operand_begin() + 1 + getSrcMemRefRank() + 1 +
|
||||
getDstMemRefRank()};
|
||||
}
|
||||
|
||||
@@ -415,8 +415,8 @@ public:
|
||||
getTagIndices() const {
|
||||
unsigned tagIndexStartPos =
|
||||
1 + getSrcMemRefRank() + 1 + getDstMemRefRank() + 1 + 1;
|
||||
return {getOperation()->operand_begin() + tagIndexStartPos,
|
||||
getOperation()->operand_begin() + tagIndexStartPos +
|
||||
return {getInstruction()->operand_begin() + tagIndexStartPos,
|
||||
getInstruction()->operand_begin() + tagIndexStartPos +
|
||||
getTagMemRefRank()};
|
||||
}
|
||||
|
||||
@@ -504,8 +504,8 @@ public:
|
||||
// Returns the tag memref index for this DMA operation.
|
||||
llvm::iterator_range<OperationInst::const_operand_iterator>
|
||||
getTagIndices() const {
|
||||
return {getOperation()->operand_begin() + 1,
|
||||
getOperation()->operand_begin() + 1 + getTagMemRefRank()};
|
||||
return {getInstruction()->operand_begin() + 1,
|
||||
getInstruction()->operand_begin() + 1 + getTagMemRefRank()};
|
||||
}
|
||||
|
||||
// Returns the rank (number of indices) of the tag memref.
|
||||
@@ -550,12 +550,14 @@ public:
|
||||
const Value *getAggregate() const { return getOperand(0); }
|
||||
|
||||
llvm::iterator_range<OperationInst::operand_iterator> getIndices() {
|
||||
return {getOperation()->operand_begin() + 1, getOperation()->operand_end()};
|
||||
return {getInstruction()->operand_begin() + 1,
|
||||
getInstruction()->operand_end()};
|
||||
}
|
||||
|
||||
llvm::iterator_range<OperationInst::const_operand_iterator>
|
||||
getIndices() const {
|
||||
return {getOperation()->operand_begin() + 1, getOperation()->operand_end()};
|
||||
return {getInstruction()->operand_begin() + 1,
|
||||
getInstruction()->operand_end()};
|
||||
}
|
||||
|
||||
static StringRef getOperationName() { return "extract_element"; }
|
||||
@@ -593,12 +595,14 @@ public:
|
||||
}
|
||||
|
||||
llvm::iterator_range<OperationInst::operand_iterator> getIndices() {
|
||||
return {getOperation()->operand_begin() + 1, getOperation()->operand_end()};
|
||||
return {getInstruction()->operand_begin() + 1,
|
||||
getInstruction()->operand_end()};
|
||||
}
|
||||
|
||||
llvm::iterator_range<OperationInst::const_operand_iterator>
|
||||
getIndices() const {
|
||||
return {getOperation()->operand_begin() + 1, getOperation()->operand_end()};
|
||||
return {getInstruction()->operand_begin() + 1,
|
||||
getInstruction()->operand_end()};
|
||||
}
|
||||
|
||||
static StringRef getOperationName() { return "load"; }
|
||||
@@ -755,12 +759,14 @@ public:
|
||||
}
|
||||
|
||||
llvm::iterator_range<OperationInst::operand_iterator> getIndices() {
|
||||
return {getOperation()->operand_begin() + 2, getOperation()->operand_end()};
|
||||
return {getInstruction()->operand_begin() + 2,
|
||||
getInstruction()->operand_end()};
|
||||
}
|
||||
|
||||
llvm::iterator_range<OperationInst::const_operand_iterator>
|
||||
getIndices() const {
|
||||
return {getOperation()->operand_begin() + 2, getOperation()->operand_end()};
|
||||
return {getInstruction()->operand_begin() + 2,
|
||||
getInstruction()->operand_end()};
|
||||
}
|
||||
|
||||
static StringRef getOperationName() { return "store"; }
|
||||
|
||||
@@ -76,5 +76,5 @@ bool DominanceInfo::properlyDominates(const Value *a, const Instruction *b) {
|
||||
|
||||
// bbarguments properly dominate all instructions in their own block, so we
|
||||
// use a dominates check here, not a properlyDominates check.
|
||||
return dominates(cast<BBArgument>(a)->getOwner(), b->getBlock());
|
||||
return dominates(cast<BlockArgument>(a)->getOwner(), b->getBlock());
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ static bool isContiguousAccess(const Value &iv, const LoadOrStoreOp &memoryOp,
|
||||
auto layoutMap = memRefType.getAffineMaps();
|
||||
// TODO(ntv): remove dependence on Builder once we support non-identity
|
||||
// layout map.
|
||||
Builder b(memoryOp.getOperation()->getContext());
|
||||
Builder b(memoryOp.getInstruction()->getContext());
|
||||
if (layoutMap.size() >= 2 ||
|
||||
(layoutMap.size() == 1 &&
|
||||
!(layoutMap[0] ==
|
||||
@@ -317,7 +317,7 @@ bool mlir::isStmtwiseShiftValid(const ForStmt &forStmt,
|
||||
if (const auto *opStmt = dyn_cast<OperationInst>(&stmt)) {
|
||||
for (unsigned i = 0, e = opStmt->getNumResults(); i < e; ++i) {
|
||||
const Value *result = opStmt->getResult(i);
|
||||
for (const StmtOperand &use : result->getUses()) {
|
||||
for (const InstOperand &use : result->getUses()) {
|
||||
// If an ancestor statement doesn't lie in the block of forStmt, there
|
||||
// is no shift to check.
|
||||
// This is a naive way. If performance becomes an issue, a map can
|
||||
|
||||
@@ -282,7 +282,7 @@ bool mlir::boundCheckLoadOrStoreOp(LoadOrStoreOpPointer loadOrStoreOp,
|
||||
std::is_same<LoadOrStoreOpPointer, OpPointer<StoreOp>>::value,
|
||||
"function argument should be either a LoadOp or a StoreOp");
|
||||
|
||||
OperationInst *opStmt = cast<OperationInst>(loadOrStoreOp->getOperation());
|
||||
OperationInst *opStmt = loadOrStoreOp->getInstruction();
|
||||
MemRefRegion region;
|
||||
if (!getMemRefRegion(opStmt, /*loopDepth=*/0, ®ion))
|
||||
return false;
|
||||
|
||||
@@ -1014,7 +1014,7 @@ protected:
|
||||
// Otherwise number it normally.
|
||||
valueIDs[value] = nextValueID++;
|
||||
return;
|
||||
case Value::Kind::StmtResult:
|
||||
case Value::Kind::InstResult:
|
||||
// This is an uninteresting result, give it a boring number and be
|
||||
// done with it.
|
||||
valueIDs[value] = nextValueID++;
|
||||
@@ -1063,7 +1063,7 @@ protected:
|
||||
resultNo = result->getResultNumber();
|
||||
lookupValue = result->getOwner()->getResult(0);
|
||||
}
|
||||
} else if (auto *result = dyn_cast<StmtResult>(value)) {
|
||||
} else if (auto *result = dyn_cast<InstResult>(value)) {
|
||||
if (result->getOwner()->getNumResults() != 1) {
|
||||
resultNo = result->getResultNumber();
|
||||
lookupValue = result->getOwner()->getResult(0);
|
||||
@@ -1235,7 +1235,7 @@ void CFGFunctionPrinter::print(const BasicBlock *block) {
|
||||
|
||||
if (!block->args_empty()) {
|
||||
os << '(';
|
||||
interleaveComma(block->getArguments(), [&](const BBArgument *arg) {
|
||||
interleaveComma(block->getArguments(), [&](const BlockArgument *arg) {
|
||||
printValueID(arg);
|
||||
os << ": ";
|
||||
printType(arg->getType());
|
||||
@@ -1340,7 +1340,7 @@ public:
|
||||
}
|
||||
|
||||
// Print loop bounds.
|
||||
void printDimAndSymbolList(ArrayRef<StmtOperand> ops, unsigned numDims);
|
||||
void printDimAndSymbolList(ArrayRef<InstOperand> ops, unsigned numDims);
|
||||
void printBound(AffineBound bound, const char *prefix);
|
||||
|
||||
// Number of spaces used for indenting nested statements.
|
||||
@@ -1451,19 +1451,20 @@ void MLFunctionPrinter::print(const ForStmt *stmt) {
|
||||
os.indent(numSpaces) << "}";
|
||||
}
|
||||
|
||||
void MLFunctionPrinter::printDimAndSymbolList(ArrayRef<StmtOperand> ops,
|
||||
void MLFunctionPrinter::printDimAndSymbolList(ArrayRef<InstOperand> ops,
|
||||
unsigned numDims) {
|
||||
auto printComma = [&]() { os << ", "; };
|
||||
os << '(';
|
||||
interleave(ops.begin(), ops.begin() + numDims,
|
||||
[&](const StmtOperand &v) { printOperand(v.get()); }, printComma);
|
||||
interleave(
|
||||
ops.begin(), ops.begin() + numDims,
|
||||
[&](const InstOperand &v) { printOperand(v.get()); }, printComma);
|
||||
os << ')';
|
||||
|
||||
if (numDims < ops.size()) {
|
||||
os << '[';
|
||||
interleave(ops.begin() + numDims, ops.end(),
|
||||
[&](const StmtOperand &v) { printOperand(v.get()); },
|
||||
printComma);
|
||||
interleave(
|
||||
ops.begin() + numDims, ops.end(),
|
||||
[&](const InstOperand &v) { printOperand(v.get()); }, printComma);
|
||||
os << ']';
|
||||
}
|
||||
}
|
||||
@@ -1503,14 +1504,14 @@ void MLFunctionPrinter::printBound(AffineBound bound, const char *prefix) {
|
||||
|
||||
// Print the map and its operands.
|
||||
printAffineMapReference(map);
|
||||
printDimAndSymbolList(bound.getStmtOperands(), map.getNumDims());
|
||||
printDimAndSymbolList(bound.getInstOperands(), map.getNumDims());
|
||||
}
|
||||
|
||||
void MLFunctionPrinter::print(const IfStmt *stmt) {
|
||||
os.indent(numSpaces) << "if ";
|
||||
IntegerSet set = stmt->getIntegerSet();
|
||||
printIntegerSetReference(set);
|
||||
printDimAndSymbolList(stmt->getStmtOperands(), set.getNumDims());
|
||||
printDimAndSymbolList(stmt->getInstOperands(), set.getNumDims());
|
||||
os << " {\n";
|
||||
print(stmt->getThen());
|
||||
os.indent(numSpaces) << "}";
|
||||
@@ -1579,7 +1580,7 @@ void Value::print(raw_ostream &os) const {
|
||||
// TODO: Improve this.
|
||||
os << "<block argument>\n";
|
||||
return;
|
||||
case Value::Kind::StmtResult:
|
||||
case Value::Kind::InstResult:
|
||||
return getDefiningInst()->print(os);
|
||||
case Value::Kind::ForStmt:
|
||||
return cast<ForStmt>(this)->print(os);
|
||||
|
||||
@@ -183,24 +183,24 @@ bool BranchOp::parse(OpAsmParser *parser, OperationState *result) {
|
||||
|
||||
void BranchOp::print(OpAsmPrinter *p) const {
|
||||
*p << "br ";
|
||||
p->printSuccessorAndUseList(getOperation(), 0);
|
||||
p->printSuccessorAndUseList(getInstruction(), 0);
|
||||
}
|
||||
|
||||
bool BranchOp::verify() const {
|
||||
// ML functions do not have branching terminators.
|
||||
if (getOperation()->getFunction()->isML())
|
||||
if (getInstruction()->getFunction()->isML())
|
||||
return (emitOpError("cannot occur in a ML function"), true);
|
||||
return false;
|
||||
}
|
||||
|
||||
BasicBlock *BranchOp::getDest() { return getOperation()->getSuccessor(0); }
|
||||
BasicBlock *BranchOp::getDest() { return getInstruction()->getSuccessor(0); }
|
||||
|
||||
void BranchOp::setDest(BasicBlock *block) {
|
||||
return getOperation()->setSuccessor(block, 0);
|
||||
return getInstruction()->setSuccessor(block, 0);
|
||||
}
|
||||
|
||||
void BranchOp::eraseOperand(unsigned index) {
|
||||
getOperation()->eraseSuccessorOperand(0, index);
|
||||
getInstruction()->eraseSuccessorOperand(0, index);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -249,14 +249,14 @@ void CondBranchOp::print(OpAsmPrinter *p) const {
|
||||
*p << "cond_br ";
|
||||
p->printOperand(getCondition());
|
||||
*p << ", ";
|
||||
p->printSuccessorAndUseList(getOperation(), trueIndex);
|
||||
p->printSuccessorAndUseList(getInstruction(), trueIndex);
|
||||
*p << ", ";
|
||||
p->printSuccessorAndUseList(getOperation(), falseIndex);
|
||||
p->printSuccessorAndUseList(getInstruction(), falseIndex);
|
||||
}
|
||||
|
||||
bool CondBranchOp::verify() const {
|
||||
// ML functions do not have branching terminators.
|
||||
if (getOperation()->getFunction()->isML())
|
||||
if (getInstruction()->getFunction()->isML())
|
||||
return (emitOpError("cannot occur in a ML function"), true);
|
||||
if (!getCondition()->getType().isInteger(1))
|
||||
return emitOpError("expected condition type was boolean (i1)");
|
||||
@@ -264,27 +264,27 @@ bool CondBranchOp::verify() const {
|
||||
}
|
||||
|
||||
BasicBlock *CondBranchOp::getTrueDest() {
|
||||
return getOperation()->getSuccessor(trueIndex);
|
||||
return getInstruction()->getSuccessor(trueIndex);
|
||||
}
|
||||
|
||||
BasicBlock *CondBranchOp::getFalseDest() {
|
||||
return getOperation()->getSuccessor(falseIndex);
|
||||
return getInstruction()->getSuccessor(falseIndex);
|
||||
}
|
||||
|
||||
unsigned CondBranchOp::getNumTrueOperands() const {
|
||||
return getOperation()->getNumSuccessorOperands(trueIndex);
|
||||
return getInstruction()->getNumSuccessorOperands(trueIndex);
|
||||
}
|
||||
|
||||
void CondBranchOp::eraseTrueOperand(unsigned index) {
|
||||
getOperation()->eraseSuccessorOperand(trueIndex, index);
|
||||
getInstruction()->eraseSuccessorOperand(trueIndex, index);
|
||||
}
|
||||
|
||||
unsigned CondBranchOp::getNumFalseOperands() const {
|
||||
return getOperation()->getNumSuccessorOperands(falseIndex);
|
||||
return getInstruction()->getNumSuccessorOperands(falseIndex);
|
||||
}
|
||||
|
||||
void CondBranchOp::eraseFalseOperand(unsigned index) {
|
||||
getOperation()->eraseSuccessorOperand(falseIndex, index);
|
||||
getInstruction()->eraseSuccessorOperand(falseIndex, index);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@@ -468,7 +468,7 @@ void ReturnOp::print(OpAsmPrinter *p) const {
|
||||
}
|
||||
|
||||
bool ReturnOp::verify() const {
|
||||
auto *function = cast<OperationInst>(getOperation())->getFunction();
|
||||
auto *function = getInstruction()->getFunction();
|
||||
|
||||
// The operand number and types must match the function signature.
|
||||
const auto &results = function->getType().getResults();
|
||||
|
||||
@@ -61,7 +61,7 @@ bool OpState::parse(OpAsmParser *parser, OperationState *result) {
|
||||
|
||||
// The fallback for the printer is to print it the longhand form.
|
||||
void OpState::print(OpAsmPrinter *p) const {
|
||||
p->printDefaultOp(getOperation());
|
||||
p->printDefaultOp(getInstruction());
|
||||
}
|
||||
|
||||
/// Emit an error about fatal conditions with this operation, reporting up to
|
||||
@@ -69,25 +69,25 @@ void OpState::print(OpAsmPrinter *p) const {
|
||||
/// the containing application, only use when the IR is in an inconsistent
|
||||
/// state.
|
||||
bool OpState::emitError(const Twine &message) const {
|
||||
return getOperation()->emitError(message);
|
||||
return getInstruction()->emitError(message);
|
||||
}
|
||||
|
||||
/// Emit an error with the op name prefixed, like "'dim' op " which is
|
||||
/// convenient for verifiers.
|
||||
bool OpState::emitOpError(const Twine &message) const {
|
||||
return getOperation()->emitOpError(message);
|
||||
return getInstruction()->emitOpError(message);
|
||||
}
|
||||
|
||||
/// Emit a warning about this operation, reporting up to any diagnostic
|
||||
/// handlers that may be listening.
|
||||
void OpState::emitWarning(const Twine &message) const {
|
||||
getOperation()->emitWarning(message);
|
||||
getInstruction()->emitWarning(message);
|
||||
}
|
||||
|
||||
/// Emit a note about this operation, reporting up to any diagnostic
|
||||
/// handlers that may be listening.
|
||||
void OpState::emitNote(const Twine &message) const {
|
||||
getOperation()->emitNote(message);
|
||||
getInstruction()->emitNote(message);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@@ -29,23 +29,23 @@
|
||||
using namespace mlir;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// StmtResult
|
||||
// InstResult
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// Return the result number of this result.
|
||||
unsigned StmtResult::getResultNumber() const {
|
||||
unsigned InstResult::getResultNumber() const {
|
||||
// Results are always stored consecutively, so use pointer subtraction to
|
||||
// figure out what number this is.
|
||||
return this - &getOwner()->getStmtResults()[0];
|
||||
return this - &getOwner()->getInstResults()[0];
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// StmtOperand
|
||||
// InstOperand
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// Return which operand this is in the operand list.
|
||||
template <> unsigned StmtOperand::getOperandNumber() const {
|
||||
return this - &getOwner()->getStmtOperands()[0];
|
||||
template <> unsigned InstOperand::getOperandNumber() const {
|
||||
return this - &getOwner()->getInstOperands()[0];
|
||||
}
|
||||
|
||||
/// Return which operand this is in the operand list.
|
||||
@@ -86,10 +86,10 @@ MLFunction *Statement::getFunction() const {
|
||||
return block ? block->getFunction() : nullptr;
|
||||
}
|
||||
|
||||
Value *Statement::getOperand(unsigned idx) { return getStmtOperand(idx).get(); }
|
||||
Value *Statement::getOperand(unsigned idx) { return getInstOperand(idx).get(); }
|
||||
|
||||
const Value *Statement::getOperand(unsigned idx) const {
|
||||
return getStmtOperand(idx).get();
|
||||
return getInstOperand(idx).get();
|
||||
}
|
||||
|
||||
// Value can be used as a dimension id if it is valid as a symbol, or
|
||||
@@ -129,7 +129,7 @@ bool Value::isValidSymbol() const {
|
||||
}
|
||||
|
||||
void Statement::setOperand(unsigned idx, Value *value) {
|
||||
getStmtOperand(idx).set(value);
|
||||
getInstOperand(idx).set(value);
|
||||
}
|
||||
|
||||
unsigned Statement::getNumOperands() const {
|
||||
@@ -143,14 +143,14 @@ unsigned Statement::getNumOperands() const {
|
||||
}
|
||||
}
|
||||
|
||||
MutableArrayRef<StmtOperand> Statement::getStmtOperands() {
|
||||
MutableArrayRef<InstOperand> Statement::getInstOperands() {
|
||||
switch (getKind()) {
|
||||
case Kind::OperationInst:
|
||||
return cast<OperationInst>(this)->getStmtOperands();
|
||||
return cast<OperationInst>(this)->getInstOperands();
|
||||
case Kind::For:
|
||||
return cast<ForStmt>(this)->getStmtOperands();
|
||||
return cast<ForStmt>(this)->getInstOperands();
|
||||
case Kind::If:
|
||||
return cast<IfStmt>(this)->getStmtOperands();
|
||||
return cast<IfStmt>(this)->getInstOperands();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ void Statement::moveBefore(StmtBlock *block,
|
||||
/// step in breaking cyclic dependences between references when they are to
|
||||
/// be deleted.
|
||||
void Statement::dropAllReferences() {
|
||||
for (auto &op : getStmtOperands())
|
||||
for (auto &op : getInstOperands())
|
||||
op.drop();
|
||||
|
||||
if (isTerminator())
|
||||
@@ -282,7 +282,7 @@ OperationInst *OperationInst::create(Location location, OperationName name,
|
||||
unsigned numOperands = operands.size() - numSuccessors;
|
||||
|
||||
auto byteSize =
|
||||
totalSizeToAlloc<StmtResult, StmtBlockOperand, unsigned, StmtOperand>(
|
||||
totalSizeToAlloc<InstResult, StmtBlockOperand, unsigned, InstOperand>(
|
||||
resultTypes.size(), numSuccessors, numSuccessors, numOperands);
|
||||
void *rawMem = malloc(byteSize);
|
||||
|
||||
@@ -292,11 +292,11 @@ OperationInst *OperationInst::create(Location location, OperationName name,
|
||||
numSuccessors, attributes, context);
|
||||
|
||||
// Initialize the results and operands.
|
||||
auto stmtResults = stmt->getStmtResults();
|
||||
auto instResults = stmt->getInstResults();
|
||||
for (unsigned i = 0, e = resultTypes.size(); i != e; ++i)
|
||||
new (&stmtResults[i]) StmtResult(resultTypes[i], stmt);
|
||||
new (&instResults[i]) InstResult(resultTypes[i], stmt);
|
||||
|
||||
auto stmtOperands = stmt->getStmtOperands();
|
||||
auto InstOperands = stmt->getInstOperands();
|
||||
|
||||
// Initialize normal operands.
|
||||
unsigned operandIt = 0, operandE = operands.size();
|
||||
@@ -307,7 +307,7 @@ OperationInst *OperationInst::create(Location location, OperationName name,
|
||||
// separately below.
|
||||
if (!operands[operandIt])
|
||||
break;
|
||||
new (&stmtOperands[nextOperand++]) StmtOperand(stmt, operands[operandIt]);
|
||||
new (&InstOperands[nextOperand++]) InstOperand(stmt, operands[operandIt]);
|
||||
}
|
||||
|
||||
unsigned currentSuccNum = 0;
|
||||
@@ -345,7 +345,7 @@ OperationInst *OperationInst::create(Location location, OperationName name,
|
||||
++currentSuccNum;
|
||||
continue;
|
||||
}
|
||||
new (&stmtOperands[nextOperand++]) StmtOperand(stmt, operands[operandIt]);
|
||||
new (&InstOperands[nextOperand++]) InstOperand(stmt, operands[operandIt]);
|
||||
++(*succOperandCountIt);
|
||||
}
|
||||
|
||||
@@ -373,11 +373,11 @@ OperationInst::OperationInst(Location location, OperationName name,
|
||||
|
||||
OperationInst::~OperationInst() {
|
||||
// Explicitly run the destructors for the operands and results.
|
||||
for (auto &operand : getStmtOperands())
|
||||
operand.~StmtOperand();
|
||||
for (auto &operand : getInstOperands())
|
||||
operand.~InstOperand();
|
||||
|
||||
for (auto &result : getStmtResults())
|
||||
result.~StmtResult();
|
||||
for (auto &result : getInstResults())
|
||||
result.~InstResult();
|
||||
|
||||
// Explicitly run the destructors for the successors.
|
||||
if (isTerminator())
|
||||
@@ -427,12 +427,12 @@ void OperationInst::setSuccessor(BasicBlock *block, unsigned index) {
|
||||
|
||||
void OperationInst::eraseOperand(unsigned index) {
|
||||
assert(index < getNumOperands());
|
||||
auto Operands = getStmtOperands();
|
||||
auto Operands = getInstOperands();
|
||||
// Shift all operands down by 1.
|
||||
std::rotate(&Operands[index], &Operands[index + 1],
|
||||
&Operands[numOperands - 1]);
|
||||
--numOperands;
|
||||
Operands[getNumOperands()].~StmtOperand();
|
||||
Operands[getNumOperands()].~InstOperand();
|
||||
}
|
||||
|
||||
auto OperationInst::getSuccessorOperands(unsigned index) const
|
||||
@@ -543,10 +543,10 @@ ForStmt *ForStmt::create(Location location, ArrayRef<Value *> lbOperands,
|
||||
|
||||
unsigned i = 0;
|
||||
for (unsigned e = lbOperands.size(); i != e; ++i)
|
||||
stmt->operands.emplace_back(StmtOperand(stmt, lbOperands[i]));
|
||||
stmt->operands.emplace_back(InstOperand(stmt, lbOperands[i]));
|
||||
|
||||
for (unsigned j = 0, e = ubOperands.size(); j != e; ++i, ++j)
|
||||
stmt->operands.emplace_back(StmtOperand(stmt, ubOperands[j]));
|
||||
stmt->operands.emplace_back(InstOperand(stmt, ubOperands[j]));
|
||||
|
||||
return stmt;
|
||||
}
|
||||
@@ -580,10 +580,10 @@ void ForStmt::setLowerBound(ArrayRef<Value *> lbOperands, AffineMap map) {
|
||||
operands.clear();
|
||||
operands.reserve(lbOperands.size() + ubMap.getNumInputs());
|
||||
for (auto *operand : lbOperands) {
|
||||
operands.emplace_back(StmtOperand(this, operand));
|
||||
operands.emplace_back(InstOperand(this, operand));
|
||||
}
|
||||
for (auto *operand : ubOperands) {
|
||||
operands.emplace_back(StmtOperand(this, operand));
|
||||
operands.emplace_back(InstOperand(this, operand));
|
||||
}
|
||||
this->lbMap = map;
|
||||
}
|
||||
@@ -597,10 +597,10 @@ void ForStmt::setUpperBound(ArrayRef<Value *> ubOperands, AffineMap map) {
|
||||
operands.clear();
|
||||
operands.reserve(lbOperands.size() + ubOperands.size());
|
||||
for (auto *operand : lbOperands) {
|
||||
operands.emplace_back(StmtOperand(this, operand));
|
||||
operands.emplace_back(InstOperand(this, operand));
|
||||
}
|
||||
for (auto *operand : ubOperands) {
|
||||
operands.emplace_back(StmtOperand(this, operand));
|
||||
operands.emplace_back(InstOperand(this, operand));
|
||||
}
|
||||
this->ubMap = map;
|
||||
}
|
||||
@@ -699,7 +699,7 @@ IfStmt *IfStmt::create(Location location, ArrayRef<Value *> operands,
|
||||
IfStmt *stmt = new IfStmt(location, numOperands, set);
|
||||
|
||||
for (auto *op : operands)
|
||||
stmt->operands.emplace_back(StmtOperand(stmt, op));
|
||||
stmt->operands.emplace_back(InstOperand(stmt, op));
|
||||
|
||||
return stmt;
|
||||
}
|
||||
@@ -749,11 +749,11 @@ Statement *Statement::clone(DenseMap<const Value *, Value *> &operandMap,
|
||||
unsigned firstSuccOperand = opStmt->getNumSuccessors()
|
||||
? opStmt->getSuccessorOperandIndex(0)
|
||||
: opStmt->getNumOperands();
|
||||
auto stmtOperands = opStmt->getStmtOperands();
|
||||
auto InstOperands = opStmt->getInstOperands();
|
||||
|
||||
unsigned i = 0;
|
||||
for (; i != firstSuccOperand; ++i)
|
||||
operands.push_back(remapOperand(stmtOperands[i].get()));
|
||||
operands.push_back(remapOperand(InstOperands[i].get()));
|
||||
|
||||
successors.reserve(opStmt->getNumSuccessors());
|
||||
for (unsigned succ = 0, e = opStmt->getNumSuccessors(); succ != e;
|
||||
|
||||
@@ -33,7 +33,7 @@ Function *Value::getFunction() {
|
||||
switch (getKind()) {
|
||||
case Value::Kind::BlockArgument:
|
||||
return cast<BlockArgument>(this)->getFunction();
|
||||
case Value::Kind::StmtResult:
|
||||
case Value::Kind::InstResult:
|
||||
return getDefiningInst()->getFunction();
|
||||
case Value::Kind::ForStmt:
|
||||
return cast<ForStmt>(this)->getFunction();
|
||||
|
||||
@@ -2621,7 +2621,7 @@ private:
|
||||
}
|
||||
|
||||
ParseResult
|
||||
parseOptionalBasicBlockArgList(SmallVectorImpl<BBArgument *> &results,
|
||||
parseOptionalBasicBlockArgList(SmallVectorImpl<BlockArgument *> &results,
|
||||
BasicBlock *owner);
|
||||
|
||||
ParseResult parseBasicBlock();
|
||||
@@ -2657,14 +2657,14 @@ bool CFGFunctionParser::parseSuccessorAndUseList(
|
||||
/// ssa-id-and-type-list ::= ssa-id-and-type (`,` ssa-id-and-type)*
|
||||
///
|
||||
ParseResult CFGFunctionParser::parseOptionalBasicBlockArgList(
|
||||
SmallVectorImpl<BBArgument *> &results, BasicBlock *owner) {
|
||||
SmallVectorImpl<BlockArgument *> &results, BasicBlock *owner) {
|
||||
if (getToken().is(Token::r_brace))
|
||||
return ParseSuccess;
|
||||
|
||||
return parseCommaSeparatedList([&]() -> ParseResult {
|
||||
auto type = parseSSADefOrUseAndType<Type>(
|
||||
[&](SSAUseInfo useInfo, Type type) -> Type {
|
||||
BBArgument *arg = owner->addArgument(type);
|
||||
BlockArgument *arg = owner->addArgument(type);
|
||||
if (addDefinition(useInfo, arg))
|
||||
return {};
|
||||
return type;
|
||||
@@ -2735,7 +2735,7 @@ ParseResult CFGFunctionParser::parseBasicBlock() {
|
||||
|
||||
// If an argument list is present, parse it.
|
||||
if (consumeIf(Token::l_paren)) {
|
||||
SmallVector<BBArgument *, 8> bbArgs;
|
||||
SmallVector<BlockArgument *, 8> bbArgs;
|
||||
if (parseOptionalBasicBlockArgList(bbArgs, block) ||
|
||||
parseToken(Token::r_paren, "expected ')' to end argument list"))
|
||||
return ParseFailure;
|
||||
|
||||
@@ -210,7 +210,7 @@ bool AllocOp::verify() const {
|
||||
// Check that the total number of operands matches the number of symbols in
|
||||
// the affine map, plus the number of dynamic dimensions specified in the
|
||||
// memref type.
|
||||
if (getOperation()->getNumOperands() != numDynamicDims + numSymbols) {
|
||||
if (getInstruction()->getNumOperands() != numDynamicDims + numSymbols) {
|
||||
return emitOpError(
|
||||
"operand count does not equal dimension plus symbol operand count");
|
||||
}
|
||||
@@ -550,7 +550,7 @@ void CmpIOp::print(OpAsmPrinter *p) const {
|
||||
assert(predicateValue >= static_cast<int>(CmpIPredicate::FirstValidValue) &&
|
||||
predicateValue < static_cast<int>(CmpIPredicate::NumPredicates) &&
|
||||
"unknown predicate index");
|
||||
Builder b(getOperation()->getContext());
|
||||
Builder b(getInstruction()->getContext());
|
||||
auto predicateStringAttr =
|
||||
b.getStringAttr(getPredicateNames()[predicateValue]);
|
||||
p->printAttribute(predicateStringAttr);
|
||||
@@ -1153,7 +1153,7 @@ bool SelectOp::parse(OpAsmParser *parser, OperationState *result) {
|
||||
|
||||
void SelectOp::print(OpAsmPrinter *p) const {
|
||||
*p << getOperationName() << ' ';
|
||||
p->printOperands(getOperation()->getOperands());
|
||||
p->printOperands(getInstruction()->getOperands());
|
||||
*p << " : " << getTrueValue()->getType();
|
||||
p->printOptionalAttrDict(getAttrs());
|
||||
}
|
||||
|
||||
@@ -88,14 +88,14 @@ void VectorTransferReadOp::build(Builder *builder, OperationState *result,
|
||||
|
||||
llvm::iterator_range<OperationInst::operand_iterator>
|
||||
VectorTransferReadOp::getIndices() {
|
||||
auto begin = getOperation()->operand_begin() + Offsets::FirstIndexOffset;
|
||||
auto begin = getInstruction()->operand_begin() + Offsets::FirstIndexOffset;
|
||||
auto end = begin + getMemRefType().getRank();
|
||||
return {begin, end};
|
||||
}
|
||||
|
||||
llvm::iterator_range<OperationInst::const_operand_iterator>
|
||||
VectorTransferReadOp::getIndices() const {
|
||||
auto begin = getOperation()->operand_begin() + Offsets::FirstIndexOffset;
|
||||
auto begin = getInstruction()->operand_begin() + Offsets::FirstIndexOffset;
|
||||
auto end = begin + getMemRefType().getRank();
|
||||
return {begin, end};
|
||||
}
|
||||
@@ -305,14 +305,14 @@ void VectorTransferWriteOp::build(Builder *builder, OperationState *result,
|
||||
|
||||
llvm::iterator_range<OperationInst::operand_iterator>
|
||||
VectorTransferWriteOp::getIndices() {
|
||||
auto begin = getOperation()->operand_begin() + Offsets::FirstIndexOffset;
|
||||
auto begin = getInstruction()->operand_begin() + Offsets::FirstIndexOffset;
|
||||
auto end = begin + getMemRefType().getRank();
|
||||
return {begin, end};
|
||||
}
|
||||
|
||||
llvm::iterator_range<OperationInst::const_operand_iterator>
|
||||
VectorTransferWriteOp::getIndices() const {
|
||||
auto begin = getOperation()->operand_begin() + Offsets::FirstIndexOffset;
|
||||
auto begin = getInstruction()->operand_begin() + Offsets::FirstIndexOffset;
|
||||
auto end = begin + getMemRefType().getRank();
|
||||
return {begin, end};
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ llvm::Value *ModuleLowerer::emitMemRefElementAccess(
|
||||
|
||||
llvm::Value *ModuleLowerer::emitMemRefAlloc(ConstOpPointer<AllocOp> allocOp) {
|
||||
MemRefType type = allocOp->getType();
|
||||
if (checkSupportedMemRefType(type, *allocOp->getOperation()))
|
||||
if (checkSupportedMemRefType(type, *allocOp->getInstruction()))
|
||||
return nullptr;
|
||||
|
||||
// Get actual sizes of the memref as values: static sizes are constant
|
||||
@@ -450,8 +450,8 @@ llvm::Value *ModuleLowerer::emitConstantSplat(const ConstantOp &op) {
|
||||
return op.emitError("NYI: only float splats are currently supported"),
|
||||
nullptr;
|
||||
|
||||
llvm::Constant *cst =
|
||||
getFloatConstant(floatAttr.getValue(), *op.getOperation(), &llvmContext);
|
||||
llvm::Constant *cst = getFloatConstant(floatAttr.getValue(),
|
||||
*op.getInstruction(), &llvmContext);
|
||||
if (!cst)
|
||||
return nullptr;
|
||||
|
||||
@@ -623,7 +623,7 @@ bool ModuleLowerer::convertInstruction(const OperationInst &inst) {
|
||||
|
||||
if (auto loadOp = inst.dyn_cast<LoadOp>()) {
|
||||
llvm::Value *element = emitMemRefElementAccess(
|
||||
loadOp->getMemRef(), *loadOp->getOperation(), loadOp->getIndices());
|
||||
loadOp->getMemRef(), *loadOp->getInstruction(), loadOp->getIndices());
|
||||
if (!element)
|
||||
return true;
|
||||
|
||||
@@ -631,8 +631,9 @@ bool ModuleLowerer::convertInstruction(const OperationInst &inst) {
|
||||
return false;
|
||||
}
|
||||
if (auto storeOp = inst.dyn_cast<StoreOp>()) {
|
||||
llvm::Value *element = emitMemRefElementAccess(
|
||||
storeOp->getMemRef(), *storeOp->getOperation(), storeOp->getIndices());
|
||||
llvm::Value *element = emitMemRefElementAccess(storeOp->getMemRef(),
|
||||
*storeOp->getInstruction(),
|
||||
storeOp->getIndices());
|
||||
if (!element)
|
||||
return true;
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ void ComposeAffineMaps::visitOperationInst(OperationInst *opStmt) {
|
||||
if (auto affineApplyOp = opStmt->dyn_cast<AffineApplyOp>()) {
|
||||
forwardSubstitute(affineApplyOp);
|
||||
bool allUsesEmpty = true;
|
||||
for (auto *result : affineApplyOp->getOperation()->getResults()) {
|
||||
for (auto *result : affineApplyOp->getInstruction()->getResults()) {
|
||||
if (!result->use_empty()) {
|
||||
allUsesEmpty = false;
|
||||
break;
|
||||
|
||||
@@ -185,7 +185,7 @@ static void rewriteAsLoops(VectorTransferOpTy *transfer,
|
||||
// case of GPUs.
|
||||
llvm::SmallVector<Value *, 1> newResults = {};
|
||||
if (std::is_same<VectorTransferOpTy, VectorTransferReadOp>::value) {
|
||||
b.setInsertionPoint(cast<OperationInst>(transfer->getOperation()));
|
||||
b.setInsertionPoint(cast<OperationInst>(transfer->getInstruction()));
|
||||
auto *vector = b.create<LoadOp>(transfer->getLoc(), vecView->getResult(),
|
||||
ArrayRef<Value *>{state->zero})
|
||||
->getResult();
|
||||
@@ -193,11 +193,11 @@ static void rewriteAsLoops(VectorTransferOpTy *transfer,
|
||||
}
|
||||
|
||||
// 6. Free the local buffer.
|
||||
b.setInsertionPoint(cast<OperationInst>(transfer->getOperation()));
|
||||
b.setInsertionPoint(transfer->getInstruction());
|
||||
b.create<DeallocOp>(transfer->getLoc(), tmpScalarAlloc);
|
||||
|
||||
// 7. It is now safe to erase the statement.
|
||||
rewriter->replaceOp(transfer->getOperation(), newResults);
|
||||
rewriter->replaceOp(transfer->getInstruction(), newResults);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -263,7 +263,7 @@ static Value *substitute(Value *v, VectorType hwVectorType,
|
||||
DenseMap<const Value *, Value *> *substitutionsMap) {
|
||||
auto it = substitutionsMap->find(v);
|
||||
if (it == substitutionsMap->end()) {
|
||||
auto *opStmt = cast<OperationInst>(v->getDefiningInst());
|
||||
auto *opStmt = v->getDefiningInst();
|
||||
if (opStmt->isa<ConstantOp>()) {
|
||||
FuncBuilder b(opStmt);
|
||||
auto *inst = instantiate(&b, opStmt, hwVectorType, substitutionsMap);
|
||||
@@ -451,7 +451,7 @@ static AffineMap projectedPermutationMap(VectorTransferOpTy *transfer,
|
||||
"Shape and ratio not of the same size");
|
||||
unsigned dim = 0;
|
||||
SmallVector<AffineExpr, 4> keep;
|
||||
MLIRContext *context = transfer->getOperation()->getContext();
|
||||
MLIRContext *context = transfer->getInstruction()->getContext();
|
||||
functional::zipApply(
|
||||
[&dim, &keep, context](int shape, int ratio) {
|
||||
assert(shape >= ratio && "shape dim must be greater than ratio dim");
|
||||
@@ -486,7 +486,7 @@ instantiate(FuncBuilder *b, VectorTransferReadOp *read, VectorType hwVectorType,
|
||||
auto cloned = b->create<VectorTransferReadOp>(
|
||||
read->getLoc(), hwVectorType, read->getMemRef(), affineIndices,
|
||||
projectedPermutationMap(read, hwVectorType), read->getPaddingValue());
|
||||
return cast<OperationInst>(cloned->getOperation());
|
||||
return cloned->getInstruction();
|
||||
}
|
||||
|
||||
/// Creates an instantiated version of `write` for the instance of
|
||||
@@ -508,7 +508,7 @@ instantiate(FuncBuilder *b, VectorTransferWriteOp *write,
|
||||
substitute(write->getVector(), hwVectorType, substitutionsMap),
|
||||
write->getMemRef(), affineIndices,
|
||||
projectedPermutationMap(write, hwVectorType));
|
||||
return cast<OperationInst>(cloned->getOperation());
|
||||
return cloned->getInstruction();
|
||||
}
|
||||
|
||||
/// Returns `true` if stmt instance is properly cloned and inserted, false
|
||||
|
||||
@@ -130,7 +130,7 @@ static bool doubleBuffer(Value *oldMemRef, ForStmt *forStmt) {
|
||||
&*forStmt->getBody()->begin())) {
|
||||
LLVM_DEBUG(llvm::dbgs()
|
||||
<< "memref replacement for double buffering failed\n";);
|
||||
ivModTwoOp->getOperation()->erase();
|
||||
ivModTwoOp->getInstruction()->erase();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -124,7 +124,7 @@ bool mlir::expandAffineApply(AffineApplyOp *op) {
|
||||
if (!op)
|
||||
return true;
|
||||
|
||||
FuncBuilder builder(cast<OperationInst>(op->getOperation()));
|
||||
FuncBuilder builder(op->getInstruction());
|
||||
auto affineMap = op->getAffineMap();
|
||||
for (auto numberedExpr : llvm::enumerate(affineMap.getResults())) {
|
||||
Value *expanded = expandAffineExpr(&builder, numberedExpr.value(), op);
|
||||
|
||||
@@ -84,7 +84,7 @@ bool mlir::replaceAllMemRefUsesWith(const Value *oldMemRef, Value *newMemRef,
|
||||
|
||||
// Walk all uses of old memref. Operation using the memref gets replaced.
|
||||
for (auto it = oldMemRef->use_begin(); it != oldMemRef->use_end();) {
|
||||
StmtOperand &use = *(it++);
|
||||
InstOperand &use = *(it++);
|
||||
auto *opStmt = cast<OperationInst>(use.getOwner());
|
||||
|
||||
// Skip this use if it's not dominated by domStmtFilter.
|
||||
@@ -145,7 +145,7 @@ bool mlir::replaceAllMemRefUsesWith(const Value *oldMemRef, Value *newMemRef,
|
||||
auto remapOp = builder.create<AffineApplyOp>(opStmt->getLoc(), indexRemap,
|
||||
remapOperands);
|
||||
// Remapped indices.
|
||||
for (auto *index : remapOp->getOperation()->getResults())
|
||||
for (auto *index : remapOp->getInstruction()->getResults())
|
||||
state.operands.push_back(index);
|
||||
} else {
|
||||
// No remapping specified.
|
||||
@@ -216,7 +216,7 @@ mlir::createComposedAffineApplyOp(FuncBuilder *builder, Location loc,
|
||||
for (unsigned i = 0, e = operands.size(); i < e; ++i) {
|
||||
(*results)[i] = affineApplyOp->getResult(i);
|
||||
}
|
||||
return cast<OperationInst>(affineApplyOp->getOperation());
|
||||
return affineApplyOp->getInstruction();
|
||||
}
|
||||
|
||||
/// Given an operation statement, inserts a new single affine apply operation,
|
||||
@@ -313,18 +313,18 @@ OperationInst *mlir::createAffineComputationSlice(OperationInst *opStmt) {
|
||||
}
|
||||
|
||||
void mlir::forwardSubstitute(OpPointer<AffineApplyOp> affineApplyOp) {
|
||||
if (!affineApplyOp->getOperation()->getFunction()->isML()) {
|
||||
if (!affineApplyOp->getInstruction()->getFunction()->isML()) {
|
||||
// TODO: Support forward substitution for CFG style functions.
|
||||
return;
|
||||
}
|
||||
auto *opStmt = cast<OperationInst>(affineApplyOp->getOperation());
|
||||
auto *opStmt = affineApplyOp->getInstruction();
|
||||
// Iterate through all uses of all results of 'opStmt', forward substituting
|
||||
// into any uses which are AffineApplyOps.
|
||||
for (unsigned resultIndex = 0, e = opStmt->getNumResults(); resultIndex < e;
|
||||
++resultIndex) {
|
||||
const Value *result = opStmt->getResult(resultIndex);
|
||||
for (auto it = result->use_begin(); it != result->use_end();) {
|
||||
StmtOperand &use = *(it++);
|
||||
InstOperand &use = *(it++);
|
||||
auto *useStmt = use.getOwner();
|
||||
auto *useOpStmt = dyn_cast<OperationInst>(useStmt);
|
||||
// Skip if use is not AffineApplyOp.
|
||||
@@ -356,7 +356,7 @@ void mlir::forwardSubstitute(OpPointer<AffineApplyOp> affineApplyOp) {
|
||||
newAffineApplyOp->getResult(i));
|
||||
}
|
||||
// Erase 'oldAffineApplyOp'.
|
||||
oldAffineApplyOp->getOperation()->erase();
|
||||
oldAffineApplyOp->getInstruction()->erase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -832,7 +832,7 @@ static bool vectorizeRootOrTerminal(Value *iv, LoadOrStoreOpPointer memoryOp,
|
||||
auto vectorType = VectorType::get(state->strategy->vectorSizes, elementType);
|
||||
|
||||
// Materialize a MemRef with 1 vector.
|
||||
auto *opStmt = cast<OperationInst>(memoryOp->getOperation());
|
||||
auto *opStmt = memoryOp->getInstruction();
|
||||
// For now, vector_transfers must be aligned, operate only on indices with an
|
||||
// identity subset of AffineMap and do not change layout.
|
||||
// TODO(ntv): increase the expressiveness power of vector_transfer operations
|
||||
@@ -846,8 +846,7 @@ static bool vectorizeRootOrTerminal(Value *iv, LoadOrStoreOpPointer memoryOp,
|
||||
auto transfer = b.create<VectorTransferReadOp>(
|
||||
opStmt->getLoc(), vectorType, memoryOp->getMemRef(),
|
||||
map(makePtrDynCaster<Value>(), memoryOp->getIndices()), permutationMap);
|
||||
state->registerReplacement(opStmt,
|
||||
cast<OperationInst>(transfer->getOperation()));
|
||||
state->registerReplacement(opStmt, transfer->getInstruction());
|
||||
} else {
|
||||
state->registerTerminator(opStmt);
|
||||
}
|
||||
@@ -974,7 +973,7 @@ static Value *vectorizeConstant(Statement *stmt, const ConstantOp &constant,
|
||||
Location loc = stmt->getLoc();
|
||||
auto vectorType = type.cast<VectorType>();
|
||||
auto attr = SplatElementsAttr::get(vectorType, constant.getValue());
|
||||
auto *constantOpStmt = cast<OperationInst>(constant.getOperation());
|
||||
auto *constantOpStmt = cast<OperationInst>(constant.getInstruction());
|
||||
|
||||
OperationState state(
|
||||
b.getContext(), loc, constantOpStmt->getName().getStringRef(), {},
|
||||
@@ -1091,7 +1090,7 @@ static OperationInst *vectorizeOneOperationInst(FuncBuilder *b,
|
||||
LLVM_DEBUG(permutationMap.print(dbgs()));
|
||||
auto transfer = b.create<VectorTransferWriteOp>(
|
||||
opStmt->getLoc(), vectorValue, memRef, indices, permutationMap);
|
||||
auto *res = cast<OperationInst>(transfer->getOperation());
|
||||
auto *res = cast<OperationInst>(transfer->getInstruction());
|
||||
LLVM_DEBUG(dbgs() << "\n[early-vect]+++++ vectorized store: " << *res);
|
||||
// "Terminators" (i.e. StoreOps) are erased on the spot.
|
||||
opStmt->erase();
|
||||
|
||||
@@ -289,10 +289,10 @@ void OpEmitter::emitAttrGetters() {
|
||||
|
||||
void OpEmitter::emitNamedOperands() {
|
||||
const auto operandMethods = R"( Value *{0}() {
|
||||
return this->getOperation()->getOperand({1});
|
||||
return this->getInstruction()->getOperand({1});
|
||||
}
|
||||
const Value *{0}() const {
|
||||
return this->getOperation()->getOperand({1});
|
||||
return this->getInstruction()->getOperand({1});
|
||||
}
|
||||
)";
|
||||
for (int i = 0, e = operands.size(); i != e; ++i) {
|
||||
|
||||
Reference in New Issue
Block a user