1 | /** |
2 | * Copyright (c) Glow Contributors. See CONTRIBUTORS file. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | #ifndef GLOW_IR_INSTRS_H |
17 | #define GLOW_IR_INSTRS_H |
18 | |
19 | #include "glow/Base/Traits.h" |
20 | #include "glow/Base/Type.h" |
21 | #include "glow/Graph/Nodes.h" |
22 | #include "glow/IR/IR.h" |
23 | |
24 | #include "llvm/ADT/ArrayRef.h" |
25 | #include "llvm/Support/Casting.h" |
26 | |
27 | namespace glow { |
28 | |
29 | class WeightVar : public Value { |
30 | public: |
31 | enum class MutabilityKind { |
32 | Constant, // A read-only region of memory. |
33 | Mutable, // A read/write region of memory. |
34 | }; |
35 | |
36 | private: |
37 | /// The mutability mode. |
38 | MutabilityKind mut_; |
39 | |
40 | public: |
41 | WeightVar(llvm::StringRef name, TypeRef Ty, MutabilityKind mut) |
42 | : Value(name, Ty, Kinded::Kind::WeightVarKind), mut_(mut) {} |
43 | |
44 | static bool classof(const Kinded *k) { |
45 | return k->getKind() == Kinded::Kind::WeightVarKind; |
46 | } |
47 | |
48 | static const char *getMutabilityStr(MutabilityKind mut); |
49 | |
50 | const char *getMutabilityStr() const; |
51 | |
52 | /// \returns true if the mutability kind of the weight is constant. |
53 | bool isConstant() const { |
54 | return getMutability() == MutabilityKind::Constant; |
55 | } |
56 | |
57 | /// \returns the mutability kind of the weight. |
58 | MutabilityKind getMutability() const { return mut_; } |
59 | |
60 | /// Updates the mutability kind of the weight to \p mut. |
61 | void setMutability(MutabilityKind mut) { mut_ = mut; } |
62 | |
63 | void dump(llvm::raw_ostream &os) const; |
64 | void verify() const {} |
65 | }; |
66 | |
67 | } // namespace glow |
68 | |
69 | // The rest of the nodes are auto-generated into this file: |
70 | #include "glow/AutoGenInstr.h" |
71 | |
72 | #endif // GLOW_IR_INSTRS_H |
73 | |