MLIR  16.0.0git
SideEffects.cpp
Go to the documentation of this file.
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 
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 
20 StringRef SideEffect::getName() const {
21  return def->getValueAsString("effect");
22 }
23 
24 StringRef SideEffect::getBaseEffectName() const {
25  return def->getValueAsString("baseEffectName");
26 }
27 
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();
33 }
34 
35 StringRef SideEffect::getResource() const {
36  return def->getValueAsString("resource");
37 }
38 
40  return var->getDef().isSubClassOf("SideEffect");
41 }
42 
43 //===----------------------------------------------------------------------===//
44 // SideEffectsTrait
45 //===----------------------------------------------------------------------===//
46 
48  auto *listInit = dyn_cast<llvm::ListInit>(def->getValueInit("effects"));
49  return {listInit->begin(), listInit->end()};
50 }
51 
53  return def->getValueAsString("baseEffectName");
54 }
55 
57  return t->getDef().isSubClassOf("SideEffectsTraitBase");
58 }
StringRef getBaseEffectName() const
Definition: SideEffects.cpp:52
static bool classof(const Trait *t)
Definition: SideEffects.cpp:56
Operator::var_decorator_range getEffects() const
Definition: SideEffects.cpp:47
StringRef getName() const
Definition: SideEffects.cpp:20
std::string getInterfaceTrait() const
Definition: SideEffects.cpp:28
StringRef getBaseEffectName() const
Definition: SideEffects.cpp:24
static bool classof(const Operator::VariableDecorator *var)
Definition: SideEffects.cpp:39
StringRef getResource() const
Definition: SideEffects.cpp:35
const llvm::Record * def
Definition: Trait.h:58
const llvm::Record & getDef() const
Definition: Trait.h:54
Include the generated interface declarations.
A class used to represent the decorators of an operator variable, i.e.
Definition: Operator.h:73
const llvm::Record & getDef() const
Definition: Operator.h:76