1 //===- SideEffects.cpp - SideEffect classes -------------------------------===// 2 // 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 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "mlir/TableGen/SideEffects.h" 10 #include "llvm/ADT/Twine.h" 11 #include "llvm/TableGen/Record.h" 12 13 using namespace mlir; 14 using namespace mlir::tblgen; 15 16 //===----------------------------------------------------------------------===// 17 // SideEffect 18 //===----------------------------------------------------------------------===// 19 getName() const20StringRef SideEffect::getName() const { 21 return def->getValueAsString("effect"); 22 } 23 getBaseEffectName() const24StringRef SideEffect::getBaseEffectName() const { 25 return def->getValueAsString("baseEffectName"); 26 } 27 getInterfaceTrait() const28std::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(); 33 } 34 getResource() const35StringRef SideEffect::getResource() const { 36 return def->getValueAsString("resource"); 37 } 38 classof(const Operator::VariableDecorator * var)39bool SideEffect::classof(const Operator::VariableDecorator *var) { 40 return var->getDef().isSubClassOf("SideEffect"); 41 } 42 43 //===----------------------------------------------------------------------===// 44 // SideEffectsTrait 45 //===----------------------------------------------------------------------===// 46 getEffects() const47Operator::var_decorator_range SideEffectTrait::getEffects() const { 48 auto *listInit = dyn_cast<llvm::ListInit>(def->getValueInit("effects")); 49 return {listInit->begin(), listInit->end()}; 50 } 51 getBaseEffectName() const52StringRef SideEffectTrait::getBaseEffectName() const { 53 return def->getValueAsString("baseEffectName"); 54 } 55 classof(const OpTrait * t)56bool SideEffectTrait::classof(const OpTrait *t) { 57 return t->getDef().isSubClassOf("SideEffectsTraitBase"); 58 } 59