MLIR  20.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 
39 int64_t SideEffect::getStage() const { return def->getValueAsInt("stage"); }
40 
42  return def->getValueAsBit("effectOnFullRegion");
43 }
44 
46  return var->getDef().isSubClassOf("SideEffect");
47 }
48 
49 //===----------------------------------------------------------------------===//
50 // SideEffectsTrait
51 //===----------------------------------------------------------------------===//
52 
54  auto *listInit = dyn_cast<llvm::ListInit>(def->getValueInit("effects"));
55  return {listInit->begin(), listInit->end()};
56 }
57 
59  return def->getValueAsString("baseEffectName");
60 }
61 
63  return t->getDef().isSubClassOf("SideEffectsTraitBase");
64 }
StringRef getBaseEffectName() const
Definition: SideEffects.cpp:58
static bool classof(const Trait *t)
Definition: SideEffects.cpp:62
Operator::var_decorator_range getEffects() const
Definition: SideEffects.cpp:53
StringRef getName() const
Definition: SideEffects.cpp:20
std::string getInterfaceTrait() const
Definition: SideEffects.cpp:28
StringRef getBaseEffectName() const
Definition: SideEffects.cpp:24
bool getEffectOnfullRegion() const
Definition: SideEffects.cpp:41
static bool classof(const Operator::VariableDecorator *var)
Definition: SideEffects.cpp:45
int64_t getStage() const
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:110
const llvm::Record & getDef() const
Definition: Operator.h:113
const llvm::Record * def
The TableGen definition of this decorator.
Definition: Operator.h:117