Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create mechanism instance struct in LLVM IR #507

Merged
merged 25 commits into from
Feb 1, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
972749c
First try adding LLVMStructBlock
iomaganaris Jan 15, 2021
28fd393
Moved get_float_variables to CodegenHelper
iomaganaris Jan 15, 2021
8ec5804
Adding float CodegenVars to LLVMStructBlock
iomaganaris Jan 15, 2021
21c82ae
Fix llvm struct printing
iomaganaris Jan 19, 2021
062f68a
Remaned struct to InstanceStruct
iomaganaris Jan 21, 2021
69bc98b
Added test and visitor
iomaganaris Jan 26, 2021
5ed7666
Fix llvm codegen tests with x[0-9].*
iomaganaris Jan 26, 2021
af96a63
WIP: Trying to add initial block with the mechanism instance struct a…
iomaganaris Jan 26, 2021
f522cb4
WIP
iomaganaris Jan 27, 2021
a4c096d
Revert "WIP"
iomaganaris Jan 27, 2021
5f40abe
Removed visit_initial_block
iomaganaris Jan 27, 2021
eaed9f4
Added declaration of global variable of type <mech>_Instance
iomaganaris Jan 27, 2021
254e2a3
Renamed global var to inst
iomaganaris Jan 28, 2021
4ddbb54
Add proper variables to the mech_Instance
iomaganaris Jan 28, 2021
d87429a
Moved info related function to codegen_info
iomaganaris Jan 28, 2021
f75db59
Update hpc-coding-conventions
iomaganaris Jan 28, 2021
2ffcc8f
Make clang-format happy
iomaganaris Jan 28, 2021
3c9d07f
Various additions
iomaganaris Jan 28, 2021
c078893
Merge branch 'llvm' into magkanar/llvm_mech_instance
iomaganaris Jan 28, 2021
525f33e
Small fix after merge
iomaganaris Jan 28, 2021
cc63bda
Other small fixes
iomaganaris Jan 28, 2021
1b8f78f
Make struct members pointers instead of doubles
iomaganaris Jan 28, 2021
00dcdfb
Use small unit test
iomaganaris Jan 28, 2021
b8726bd
Merge branch 'llvm' into magkanar/llvm_mech_instance
pramodk Feb 1, 2021
bf1b584
minor indentation fix
pramodk Feb 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
292 changes: 33 additions & 259 deletions src/codegen/codegen_c_visitor.cpp

Large diffs are not rendered by default.

123 changes: 0 additions & 123 deletions src/codegen/codegen_c_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,41 +67,6 @@ enum class MemberType {
};


/**
* \class IndexVariableInfo
* \brief Helper to represent information about index/int variables
*
*/
struct IndexVariableInfo {
/// symbol for the variable
const std::shared_ptr<symtab::Symbol> symbol;

/// if variable reside in vdata field of NrnThread
/// typically true for bbcore pointer
bool is_vdata = false;

/// if this is pure index (e.g. style_ion) variables is directly
/// index and shouldn't be printed with data/vdata
bool is_index = false;

/// if this is an integer (e.g. tqitem, point_process) variable which
/// is printed as array accesses
bool is_integer = false;

/// if the variable is qualified as constant (this is property of IndexVariable)
bool is_constant = false;

IndexVariableInfo(std::shared_ptr<symtab::Symbol> symbol,
bool is_vdata = false,
bool is_index = false,
bool is_integer = false)
: symbol(std::move(symbol))
, is_vdata(is_vdata)
, is_index(is_index)
, is_integer(is_integer) {}
};


/**
* \enum LayoutType
* \brief Represents memory layout to use for code generation
Expand Down Expand Up @@ -178,11 +143,6 @@ class CodegenCVisitor: public visitor::ConstAstVisitor {
*/
symtab::SymbolTable* program_symtab = nullptr;

/**
* All float variables for the model
*/
std::vector<SymbolType> codegen_float_variables;

/**
* All int variables for the model
*/
Expand Down Expand Up @@ -376,26 +336,6 @@ class CodegenCVisitor: public visitor::ConstAstVisitor {
}


/**
* Constructs a shadow variable name
* \param name The name of the variable
* \return The name of the variable prefixed with \c shadow_
*/
std::string shadow_varname(const std::string& name) const {
return "shadow_" + name;
}


/**
* Creates a temporary symbol
* \param name The name of the symbol
* \return A symbol based on the given name
*/
SymbolType make_symbol(const std::string& name) const {
return std::make_shared<symtab::Symbol>(name, ModToken());
}


/**
* Checks if the given variable name belongs to a state variable
* \param name The variable name
Expand All @@ -404,55 +344,13 @@ class CodegenCVisitor: public visitor::ConstAstVisitor {
bool state_variable(const std::string& name) const;


/**
* Check if net receive/send buffering kernels required
*/
bool net_receive_buffering_required() const noexcept;


/**
* Check if nrn_state function is required
*/
bool nrn_state_required() const noexcept;


/**
* Check if nrn_cur function is required
*/
bool nrn_cur_required() const noexcept;


/**
* Check if net_receive function is required
*/
bool net_receive_required() const noexcept;


/**
* Check if net_send_buffer is required
*/
bool net_send_buffer_required() const noexcept;


/**
* Check if setup_range_variable function is required
* \return
*/
bool range_variable_setup_required() const noexcept;


/**
* Check if net_receive node exist
*/
bool net_receive_exist() const noexcept;


/**
* Check if breakpoint node exist
*/
bool breakpoint_exist() const noexcept;


/**
* Check if given method is defined in this model
* \param name The name of the method to check
Expand Down Expand Up @@ -618,27 +516,6 @@ class CodegenCVisitor: public visitor::ConstAstVisitor {
void update_index_semantics();


/**
* Determine all \c float variables required during code generation
* \return A \c vector of \c float variables
*/
std::vector<SymbolType> get_float_variables();


/**
* Determine all \c int variables required during code generation
* \return A \c vector of \c int variables
*/
std::vector<IndexVariableInfo> get_int_variables();


/**
* Determine all ion write variables that require shadow vectors during code generation
* \return A \c vector of ion variables
*/
std::vector<SymbolType> get_shadow_variables();


/**
* Print the items in a vector as a list
*
Expand Down
5 changes: 5 additions & 0 deletions src/codegen/codegen_helper_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ using namespace ast;
using symtab::syminfo::NmodlType;
using symtab::syminfo::Status;


/**
* How symbols are stored in NEURON? See notes written in markdown file.
*
Expand Down Expand Up @@ -273,6 +274,7 @@ void CodegenHelperVisitor::find_non_range_variables() {
// clang-format on
}


/**
* Find range variables i.e. ones that are belong to per instance allocation
*
Expand Down Expand Up @@ -658,6 +660,9 @@ void CodegenHelperVisitor::visit_program(const ast::Program& node) {
find_range_variables();
find_non_range_variables();
find_table_variables();
info.get_int_variables();
info.get_shadow_variables();
info.get_float_variables();
}


Expand Down
10 changes: 10 additions & 0 deletions src/codegen/codegen_helper_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ class CodegenHelperVisitor: public visitor::ConstAstVisitor {
void find_non_range_variables();
void sort_with_mod2c_symbol_order(std::vector<SymbolType>& symbols) const;

/**
* Check if breakpoint node exist
*/
bool breakpoint_exist() const noexcept;

/**
* Check if net_receive node exist
*/
bool net_receive_exist() const noexcept;

public:
CodegenHelperVisitor() = default;

Expand Down
Loading