1 //===- SideEffects.cpp - SideEffect classes -------------------------------===//
3 // Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "mlir/TableGen/SideEffects.h"
10 #include "llvm/ADT/Twine.h"
11 #include "llvm/TableGen/Record.h"
14 using namespace mlir::tblgen
;
16 //===----------------------------------------------------------------------===//
18 //===----------------------------------------------------------------------===//
20 StringRef
SideEffect::getName() const {
21 return def
->getValueAsString("effect");
24 StringRef
SideEffect::getBaseEffectName() const {
25 return def
->getValueAsString("baseEffectName");
28 std::string
SideEffect::getInterfaceTrait() const {
29 StringRef trait
= def
->getValueAsString("interfaceTrait");
30 StringRef cppNamespace
= def
->getValueAsString("cppNamespace");
31 return cppNamespace
.empty() ? trait
.str()
32 : (cppNamespace
+ "::" + trait
).str();
35 StringRef
SideEffect::getResource() const {
36 return def
->getValueAsString("resource");
39 int64_t SideEffect::getStage() const { return def
->getValueAsInt("stage"); }
41 bool SideEffect::getEffectOnfullRegion() const {
42 return def
->getValueAsBit("effectOnFullRegion");
45 bool SideEffect::classof(const Operator::VariableDecorator
*var
) {
46 return var
->getDef().isSubClassOf("SideEffect");
49 //===----------------------------------------------------------------------===//
51 //===----------------------------------------------------------------------===//
53 Operator::var_decorator_range
SideEffectTrait::getEffects() const {
54 auto *listInit
= dyn_cast
<llvm::ListInit
>(def
->getValueInit("effects"));
55 return {listInit
->begin(), listInit
->end()};
58 StringRef
SideEffectTrait::getBaseEffectName() const {
59 return def
->getValueAsString("baseEffectName");
62 bool SideEffectTrait::classof(const Trait
*t
) {
63 return t
->getDef().isSubClassOf("SideEffectsTraitBase");