
[MLIR] Add stage and effectOnFullRegion to side effect This patch add stage and effectOnFullRegion to side effect for optimization pass to obtain more accurate information. Stage uses numbering to track the side effects's stage of occurrence. EffectOnFullRegion indicates if effect act on every single value of resource. RFC disscussion: https://discourse.llvm.org/t/rfc-add-effect-index-in-memroy-effect/72235 Differential Revision: https://reviews.llvm.org/D156087 Reviewed By: mehdi_amini, Mogball Differential Revision: https://reviews.llvm.org/D156087
65 lines
2.1 KiB
C++
65 lines
2.1 KiB
C++
//===- 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/ADT/Twine.h"
|
|
#include "llvm/TableGen/Record.h"
|
|
|
|
using namespace mlir;
|
|
using namespace mlir::tblgen;
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
// SideEffect
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
StringRef SideEffect::getName() const {
|
|
return def->getValueAsString("effect");
|
|
}
|
|
|
|
StringRef SideEffect::getBaseEffectName() const {
|
|
return def->getValueAsString("baseEffectName");
|
|
}
|
|
|
|
std::string SideEffect::getInterfaceTrait() const {
|
|
StringRef trait = def->getValueAsString("interfaceTrait");
|
|
StringRef cppNamespace = def->getValueAsString("cppNamespace");
|
|
return cppNamespace.empty() ? trait.str()
|
|
: (cppNamespace + "::" + trait).str();
|
|
}
|
|
|
|
StringRef SideEffect::getResource() const {
|
|
return def->getValueAsString("resource");
|
|
}
|
|
|
|
int64_t SideEffect::getStage() const { return def->getValueAsInt("stage"); }
|
|
|
|
bool SideEffect::getEffectOnfullRegion() const {
|
|
return def->getValueAsBit("effectOnFullRegion");
|
|
}
|
|
|
|
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()};
|
|
}
|
|
|
|
StringRef SideEffectTrait::getBaseEffectName() const {
|
|
return def->getValueAsString("baseEffectName");
|
|
}
|
|
|
|
bool SideEffectTrait::classof(const Trait *t) {
|
|
return t->getDef().isSubClassOf("SideEffectsTraitBase");
|
|
}
|