-
Notifications
You must be signed in to change notification settings - Fork 16
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
Function call support #472
Comments
In theory yes but for what would like to do here, we can assume all functions are defined in the mod file.
IIRC, I read somewhere in language reference guide that order of method definitions doesn’t matter in the same modules. So prototype declaration is not required (?) |
Because traversing AST first meets If NMODL takes care of these cases already, then we can assume all functions in calls have been processed beforehand. |
Understood now! NMODL doesn't handle this i.e. order in the AST is same as how user write. For this reason, C++ code generation backend does emit prototype declarations for all functions and procedure at the beginning. IIRC, prototype declaration is straightforward in LLVM IR, right? In that case it would be safe to emit them at the beginning. I suggest two options:
Basically, in visit_program(const Program& node) {
CodegenHelperVisitor v;
auto& info = v.analyze(node);
for (const auto& node: info.functions) {
// emit declaration
}
for (const auto& node: info.procedures) {
// emit declaration
}
....
} We do the same in C++ backend here nmodl/src/codegen/codegen_c_visitor.cpp Line 1416 in ab27595
|
Thanks! Yes, I just wanted to clarify before implementing these. I think that emitting declarations is a good and rather straightforward approach. |
This patch adds support for function call code generation, particularly: - User-defined procedures and functions can now lowered to LLVM IR. - A framework for external method calls (e.g. sin, exp, etc.) has been created, currently `exp` and `pow` are supported. - Corresponding tests added. fixes #472
This patch adds support for function call code generation, particularly: - User-defined procedures and functions can now lowered to LLVM IR. - A framework for external method calls (e.g. sin, exp, etc.) has been created, currently `exp` and `pow` are supported. - Corresponding tests added. fixes #472
This patch adds support for function call code generation, particularly: - User-defined procedures and functions can now lowered to LLVM IR. - A framework for external method calls (e.g. sin, exp, etc.) has been created, currently `exp` and `pow` are supported. - Corresponding tests added. fixes #472
This patch adds support for function call code generation, particularly: - User-defined procedures and functions can now lowered to LLVM IR. - A framework for external method calls (e.g. sin, exp, etc.) has been created, currently `exp` and `pow` are supported. - Corresponding tests added. fixes #472
This patch adds support for function call code generation, particularly: - User-defined procedures and functions can now lowered to LLVM IR. - A framework for external method calls (e.g. sin, exp, etc.) has been created, currently `exp` and `pow` are supported. - Corresponding tests added. fixes #472
This patch adds support for function call code generation, particularly: - User-defined procedures and functions can now lowered to LLVM IR. - A framework for external method calls (e.g. sin, exp, etc.) has been created, currently `exp` and `pow` are supported. - Corresponding tests added. fixes #472
This patch adds support for function call code generation, particularly: - User-defined procedures and functions can now lowered to LLVM IR. - A framework for external method calls (e.g. sin, exp, etc.) has been created, currently `exp` and `pow` are supported. - Corresponding tests added. fixes #472
Support function calls in NMODL
Question: can we call function external to the current mod file?
Question: does ordering of functions matter? (do we need declarations?)
The text was updated successfully, but these errors were encountered: