2020-03-07 05:55:36 +08:00
|
|
|
//===- SideEffects.cpp - SideEffect classes -------------------------------===//
|
|
|
|
//
|
|
|
|
// Part of the MLIR 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/TableGen/SideEffects.h"
|
|
|
|
#include "llvm/TableGen/Record.h"
|
|
|
|
|
|
|
|
using namespace mlir;
|
|
|
|
using namespace mlir::tblgen;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// SideEffect
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
StringRef SideEffect::getName() const {
|
|
|
|
return def->getValueAsString("effect");
|
|
|
|
}
|
|
|
|
|
2020-03-13 05:06:41 +08:00
|
|
|
StringRef SideEffect::getBaseEffectName() const {
|
|
|
|
return def->getValueAsString("baseEffectName");
|
2020-03-07 05:55:36 +08:00
|
|
|
}
|
|
|
|
|
[MLIR] Propagate input side effect information
Summary:
Previously operations like std.load created methods for obtaining their
effects but did not inherit from the SideEffect interfaces when their
parameters were decorated with the information. The resulting situation
was that passes had no information on the SideEffects of std.load/store
and had to treat them more cautiously. This adds the inheritance
information when creating the methods.
As a side effect, many tests are modified, as they were using std.load
for testing and this oepration would be folded away as part of pattern
rewriting. Tests are modified to use store or to reutn the result of the
std.load.
Reviewers: mravishankar, antiagainst, nicolasvasilache, herhut, aartbik, ftynse!
Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, csigg, arpith-jacob, mgester, lucyrfox, liufengdb, Joonsoo, bader, grosul1, frgossen, Kayjukh, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D78802
2020-04-24 00:13:44 +08:00
|
|
|
StringRef SideEffect::getInterfaceTrait() const {
|
|
|
|
return def->getValueAsString("interfaceTrait");
|
|
|
|
}
|
|
|
|
|
2020-03-07 05:55:36 +08:00
|
|
|
StringRef SideEffect::getResource() const {
|
2020-04-27 19:46:04 +08:00
|
|
|
return def->getValueAsString("resource");
|
2020-03-07 05:55:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SideEffect::classof(const Operator::VariableDecorator *var) {
|
|
|
|
return var->getDef().isSubClassOf("SideEffect");
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// SideEffectsTrait
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
Operator::var_decorator_range SideEffectTrait::getEffects() const {
|
|
|
|
auto *listInit = dyn_cast<llvm::ListInit>(def->getValueInit("effects"));
|
|
|
|
return {listInit->begin(), listInit->end()};
|
|
|
|
}
|
|
|
|
|
2020-03-13 05:06:41 +08:00
|
|
|
StringRef SideEffectTrait::getBaseEffectName() const {
|
|
|
|
return def->getValueAsString("baseEffectName");
|
|
|
|
}
|
|
|
|
|
2020-03-07 05:55:36 +08:00
|
|
|
bool SideEffectTrait::classof(const OpTrait *t) {
|
|
|
|
return t->getDef().isSubClassOf("SideEffectsTraitBase");
|
|
|
|
}
|