systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
ModuleInstanceType.h
Go to the documentation of this file.
1#ifndef _MODULE_INSTANCE_TYPE_
2#define _MODULE_INSTANCE_TYPE_
3
4#include <string>
5
7namespace clang {
8class Decl;
9}
10
11#undef DEBUG_TYPE
12#define DEBUG_TYPE "Dump"
13
14namespace sc_ast_matchers {
15
17 std::string var_name;
18 std::string var_type_name;
19 std::string instance_name;
20 std::string
21 parent_name; // This is the name of the class that holds the field.
23 clang::Decl *type_decl;
24 clang::Decl *instance_decl;
25 clang::ValueDecl *parent_decl;
27 // Arrays can have multiple names.
28 std::vector<std::string> instance_names;
29
30 void add_instance_name(const std::string &name) {
31 instance_names.push_back(name);
32 }
33 std::vector<std::string> getInstanceNames() { return instance_names; }
34
35 // Array fields
37 std::vector<llvm::APInt> array_sizes_;
38 typedef std::tuple<std::size_t, std::size_t, std::size_t> ArrayParamType;
40
41 clang::Decl *getInstanceTypeDecl() const { return type_decl; }
42 clang::Decl *getInstanceDecl() const { return instance_decl; }
43 clang::ValueDecl *getParentDecl() const { return parent_decl; }
44 std::string getVarName() const { return var_name; }
45
47 void setArrayType() { is_array_ = true; }
50 bool isArrayType() { return is_array_; }
51
55 unsigned int getArrayDimension() const { return array_sizes_.size(); }
56
57 void addArraySizes(std::vector<llvm::APInt> sizes) { array_sizes_ = sizes; }
58 std::vector<llvm::APInt> getArraySizes() { return array_sizes_; }
59
61 : var_name{},
65 is_field_decl{false},
66 type_decl{nullptr},
67 instance_decl{nullptr},
68 parent_decl{nullptr},
69 is_array_{false},
71
86
102
114
115 void dump() {
116 llvm::outs() << "ModuleInstanceMap -- type_decl: " << type_decl
117 << " inst_decl: " << instance_decl
118 << " var_type_name: " << var_type_name
119 << " var_name: " << var_name
120 << " instance_name: " << instance_name
121 << " parent_name: " << parent_name
122 << " parent_decl: " << parent_decl
123 << " is_field_decl: " << is_field_decl
124 << " is_array_: " << is_array_ << "\n";
125
126 llvm::outs() << "Array sizes: " << array_sizes_.size() << " -- ";
127 for (auto const &size : array_sizes_) {
128 llvm::outs() << size << " ";
129 }
130
131 if (instance_names.size() > 0) {
132 llvm::outs() << "instance_names: ";
133 }
134
135 for (const auto &name : instance_names) {
136 llvm::outs() << name;
137 }
138 llvm::outs() << "\n";
139 llvm::outs() << "Array parameters: " << getArrayDimension() << "\n";
140 llvm::outs() << "[x][y][z]: " << std::get<0>(array_parameters_) << ","
141 << std::get<1>(array_parameters_) << ","
142 << std::get<2>(array_parameters_) << "\n";
143 }
144};
145}; // namespace sc_ast_matchers
146
147#endif
Clang forward declarations.
Definition FindArgument.h:6
unsigned int getArrayDimension() const
Return the array dimension, if the module instance is an array. 0 means a single instance k means kD ...
void add_instance_name(const std::string &name)
std::vector< std::string > getInstanceNames()
void setArrayParameters(ArrayParamType parm)
std::vector< llvm::APInt > getArraySizes()
clang::ValueDecl * getParentDecl() const
std::tuple< std::size_t, std::size_t, std::size_t > ArrayParamType
ModuleInstanceType(const ModuleInstanceType &rhs)
std::vector< std::string > instance_names
std::vector< llvm::APInt > array_sizes_
void addArraySizes(std::vector< llvm::APInt > sizes)
ModuleInstanceType & operator=(const ModuleInstanceType &rhs)
bool operator==(const ModuleInstanceType &rhs)