-
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
Georgemitenkov/llvm indexed names #478
Conversation
Can one of the admins verify this patch? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm except the comment about using macro values from global symtab.
} | ||
|
||
unsigned CodegenLLVMVisitor::get_array_index_or_length(const ast::IndexedName& indexed_name) { | ||
auto integer = dynamic_cast<ast::Integer*>(indexed_name.get_length().get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a stylistic comment : there is also dynamic_pointer_cast
with which you don't need .get()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for letting me know about this!
if (!integer->get_macro()) | ||
return integer->get_value(); | ||
return macros[integer->get_macro()->get_node_name()]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the global symbol table we store macros and their values. Can that be used?
[NMODL] [info] :: Printing symbol table
--------------------------------------------------------------------------------------------------------
| NMODL_GLOBAL [Program IN None] POSITION : UNKNOWN SCOPE : GLOBAL |
--------------------------------------------------------------------------------------------------------
| NAME | PROPERTIES | STATUS | LOCATION | VALUE | # READS | # WRITES |
--------------------------------------------------------------------------------------------------------
| t | extern_neuron_var | | EXTERNAL | | 1 | 0 |
| v | extern_neuron_var | | EXTERNAL | | 1 | 0 |
| N | define | | UNKNOWN | 100.000000 | 0 | 0 |
@@ -165,6 +210,10 @@ void CodegenLLVMVisitor::visit_boolean(const ast::Boolean& node) { | |||
values.push_back(constant); | |||
} | |||
|
|||
void CodegenLLVMVisitor::visit_define(const ast::Define& node) { | |||
macros[node.get_node_name()] = node.get_value()->get_value(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as before : can the symtab be used for this purpose?
* \param index element index | ||
* \return GEP instruction value | ||
*/ | ||
llvm::Value* create_GEP(const std::string& name, unsigned index); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick : stylistically, in nmodl we would write as create_gep
(but it's true that in LLVM method has GEP
)
2f03bd3
to
a6cd161
Compare
@pramodk I used a symbol table instead! However, while testing, I noticed that in C visitor, the macro doesn't seem to be expanded?
gives
and there is no definition of N as well. |
Oops..that's a bug! Didn't notice that earlier as local array is not commonly used. 😒 Could you create an issue with above code snippet? I will then take care of this in C codegen. |
Created an issue :) It seems like only occurring when used for array sizes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LLVM code generation for `IndexedName`s. - Added code generation for initialising arrays in LOCAL blocks (with both integer constants and macros). - Added support for indexing arrays. fixes #467
LLVM code generation for `IndexedName`s. - Added code generation for initialising arrays in LOCAL blocks (with both integer constants and macros). - Added support for indexing arrays. fixes #467
LLVM code generation for `IndexedName`s. - Added code generation for initialising arrays in LOCAL blocks (with both integer constants and macros). - Added support for indexing arrays. fixes #467
LLVM code generation for `IndexedName`s. - Added code generation for initialising arrays in LOCAL blocks (with both integer constants and macros). - Added support for indexing arrays. fixes #467
LLVM code generation for `IndexedName`s. - Added code generation for initialising arrays in LOCAL blocks (with both integer constants and macros). - Added support for indexing arrays. fixes #467
LLVM code generation for `IndexedName`s. - Added code generation for initialising arrays in LOCAL blocks (with both integer constants and macros). - Added support for indexing arrays. fixes #467
This PR addresses
IndexedName
s, adding the following:Note that this handles 1D arrays (same as NMODL)
Also, codegen for
DEFINE
node has been implemented: macros are currently stored in a dedicated map.fixes #467