Talvos  0.1
SPIR-V interpreter and dynamic analysis framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Variable.h
Go to the documentation of this file.
1 // Copyright (c) 2018 the Talvos developers. All rights reserved.
2 //
3 // This file is distributed under a three-clause BSD license. For full license
4 // terms please see the LICENSE file distributed with this source code.
5 
8 
9 #ifndef TALVOS_VARIABLE_H
10 #define TALVOS_VARIABLE_H
11 
12 #include <cstdint>
13 #include <map>
14 
15 namespace talvos
16 {
17 
18 class Type;
19 
21 class Variable
22 {
23 public:
25  Variable(uint32_t Id, const Type *Ty, uint32_t Initializer = 0);
26 
28  void addDecoration(uint32_t Decoration, uint32_t Data);
29 
32  uint32_t getDecoration(uint32_t Decoration) const;
33 
35  uint32_t getId() const { return Id; }
36 
38  uint32_t getInitializer() const { return Initializer; }
39 
41  const Type *getType() const { return Ty; }
42 
44  bool hasDecoration(uint32_t Decoration) const;
45 
47  bool isBufferVariable() const;
48 
49 private:
51  uint32_t Id;
52 
54  const Type *Ty;
55 
57  uint32_t Initializer;
58 
60  std::map<uint32_t, uint32_t> Decorations;
61 };
62 
63 } // namespace talvos
64 
65 #endif
This class represents a module-scope variable declaration.
Definition: Variable.h:21
uint32_t Id
Result ID of the variable.
Definition: Variable.h:51
bool isBufferVariable() const
Returns true if this variable has a buffer or uniform storage class.
Definition: Variable.cpp:38
Variable(uint32_t Id, const Type *Ty, uint32_t Initializer=0)
Create a module scope variable with an optional initializer.
Definition: Variable.cpp:18
const Type * getType() const
Returns the type of this variable.
Definition: Variable.h:41
std::map< uint32_t, uint32_t > Decorations
Map of decorations.
Definition: Variable.h:60
uint32_t getDecoration(uint32_t Decoration) const
Returns the decoration data associated with this variable.
Definition: Variable.cpp:27
uint32_t getInitializer() const
Returns the result ID of this variables initializer, or 0 if not present.
Definition: Variable.h:38
uint32_t Initializer
Result ID of the initializer.
Definition: Variable.h:57
uint32_t getId() const
Returns the result ID of this variable.
Definition: Variable.h:35
void addDecoration(uint32_t Decoration, uint32_t Data)
Add a decoration to this variable.
Definition: Variable.cpp:22
const Type * Ty
Type of the variable.
Definition: Variable.h:54
This class represents a SPIR-V type.
Definition: Type.h:33
bool hasDecoration(uint32_t Decoration) const
Returns true if this variable has been decorated with Decoration.
Definition: Variable.cpp:33