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

Initial LLVM codegen vistor routines #457

Merged
merged 19 commits into from
Dec 22, 2020
Merged

Conversation

georgemitenkov
Copy link
Collaborator

This is a first draft of LLVM codegen. At the moment, the following NMODL constructs are supported:

  • PROCEDURE
  • LOCAL VAR
  • Arithmetic binary (+, -, *, and /) and unary (-) ops

More tests to cover these cases will be added.

@bbpbuildbot
Copy link
Collaborator

Can one of the admins verify this patch?

1 similar comment
@bbpbuildbot
Copy link
Collaborator

Can one of the admins verify this patch?

@alkino alkino added the llvm label Dec 15, 2020
Copy link
Contributor

@pramodk pramodk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice @georgemitenkov !

I have just put some minor comments about code style etc. Please take a look and make changes as you seem necessary.

src/codegen/llvm/codegen_llvm_visitor.cpp Outdated Show resolved Hide resolved
src/codegen/llvm/codegen_llvm_visitor.cpp Show resolved Hide resolved
src/codegen/llvm/codegen_llvm_visitor.cpp Show resolved Hide resolved
src/codegen/llvm/codegen_llvm_visitor.cpp Outdated Show resolved Hide resolved
src/codegen/llvm/codegen_llvm_visitor.cpp Show resolved Hide resolved
std::vector<llvm::Type*> arg_types;
for (unsigned i = 0, e = parameters.size(); i < e; ++i)
arg_types.push_back(llvm::Type::getDoubleTy(*context));
llvm::Type* return_type = llvm::Type::getVoidTy(*context);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick : indentation

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, what is the indentation used for the project? I noticed that headers use 2 spaces, and implementation uses 4 spaces. So I will just use that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I was mistaken here. I see that line 103 is indented for loop!

For indentation, we use 4 spaces everywhere. In fact, assuming you have clang-format 8/9/10, and cmake option -DNMODL_CLANG_FORMAT=ON, doing make clang-format should format everything consistently!

If you see 2 spaces somewhere, let me know.

src/codegen/llvm/codegen_llvm_visitor.cpp Outdated Show resolved Hide resolved
src/codegen/llvm/codegen_llvm_visitor.cpp Outdated Show resolved Hide resolved
src/codegen/llvm/codegen_llvm_visitor.cpp Outdated Show resolved Hide resolved
src/codegen/llvm/codegen_llvm_visitor.hpp Outdated Show resolved Hide resolved
@pramodk
Copy link
Contributor

pramodk commented Dec 18, 2020

By the way, CI is failing but I fix that once address the comment and make PR ready.

@georgemitenkov georgemitenkov marked this pull request as ready for review December 21, 2020 16:00
@pramodk
Copy link
Contributor

pramodk commented Dec 21, 2020

retest this please

1 similar comment
@pramodk
Copy link
Contributor

pramodk commented Dec 21, 2020

retest this please

@pramodk pramodk force-pushed the georgemitenkov/llvm branch from f5ee8da to a21e170 Compare December 21, 2020 21:43
neg instruction is different for older LLVM version 9 and 11
Disable docs building on travis
Disable python bindings on travis
@pramodk pramodk force-pushed the georgemitenkov/llvm branch from 7710aba to ed9f0fe Compare December 21, 2020 23:07
Copy link
Contributor

@pramodk pramodk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@georgemitenkov : this is in good shape to merge with llvm branch. I think I have done necessary changes to pass CI. Also, I have removed/disabled some CI checks that are not necessary for this LLVM branch.

If all CI passes, go ahead with merge. For PRs we typically do squash and merge:

image

And just fyi : while squash & merge, we re-write commit message in following form:

image

i.e. bullet points summarising the PR and fixes or closes keyword with issue number to automatically close related issues.

llvm_map_components_to_libnames(LLVM_LIBS_TO_LINK core)
set(CMAKE_REQUIRED_INCLUDES ${LLVM_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${LLVM_LIBS_TO_LINK})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI : I changed this because this was a bug - we were finding LLVM only for Clang compiler.

src/codegen/llvm/codegen_llvm_visitor.cpp Show resolved Hide resolved
@georgemitenkov georgemitenkov merged commit 6f66c71 into llvm Dec 22, 2020
@georgemitenkov georgemitenkov deleted the georgemitenkov/llvm branch December 22, 2020 10:54
@georgemitenkov georgemitenkov restored the georgemitenkov/llvm branch December 22, 2020 10:54
pramodk added a commit that referenced this pull request Feb 23, 2021
* Added LLVM code generation for `ProcedureBlock`.
* Added code generation routines for double, integer and
   boolean variable types. 
* Added binary and unary operator code generation:
     - Supported binary operators: +, -, *, /.
     - Supported unary operators: -.
     - Assignment (=) is also supported.
* Added regex matching unit tests for LLVM code generation.
* Fixed Travis CI/builds.

fixes #451, fixes #452, fixes #456

Co-authored-by: Pramod Kumbhar <pramod.s.kumbhar@gmail.com>
pramodk added a commit that referenced this pull request May 8, 2021
* Added LLVM code generation for `ProcedureBlock`.
* Added code generation routines for double, integer and
   boolean variable types.
* Added binary and unary operator code generation:
     - Supported binary operators: +, -, *, /.
     - Supported unary operators: -.
     - Assignment (=) is also supported.
* Added regex matching unit tests for LLVM code generation.
* Fixed Travis CI/builds.

fixes #451, fixes #452, fixes #456

Co-authored-by: Pramod Kumbhar <pramod.s.kumbhar@gmail.com>
pramodk added a commit that referenced this pull request Mar 8, 2022
* Added LLVM code generation for `ProcedureBlock`.
* Added code generation routines for double, integer and
   boolean variable types.
* Added binary and unary operator code generation:
     - Supported binary operators: +, -, *, /.
     - Supported unary operators: -.
     - Assignment (=) is also supported.
* Added regex matching unit tests for LLVM code generation.
* Fixed Travis CI/builds.

fixes #451, fixes #452, fixes #456

Co-authored-by: Pramod Kumbhar <pramod.s.kumbhar@gmail.com>
iomaganaris pushed a commit that referenced this pull request May 10, 2022
* Added LLVM code generation for `ProcedureBlock`.
* Added code generation routines for double, integer and
   boolean variable types.
* Added binary and unary operator code generation:
     - Supported binary operators: +, -, *, /.
     - Supported unary operators: -.
     - Assignment (=) is also supported.
* Added regex matching unit tests for LLVM code generation.
* Fixed Travis CI/builds.

fixes #451, fixes #452, fixes #456

Co-authored-by: Pramod Kumbhar <pramod.s.kumbhar@gmail.com>
iomaganaris pushed a commit that referenced this pull request May 12, 2022
* Added LLVM code generation for `ProcedureBlock`.
* Added code generation routines for double, integer and
   boolean variable types.
* Added binary and unary operator code generation:
     - Supported binary operators: +, -, *, /.
     - Supported unary operators: -.
     - Assignment (=) is also supported.
* Added regex matching unit tests for LLVM code generation.
* Fixed Travis CI/builds.

fixes #451, fixes #452, fixes #456

Co-authored-by: Pramod Kumbhar <pramod.s.kumbhar@gmail.com>
iomaganaris pushed a commit that referenced this pull request Sep 15, 2022
* Added LLVM code generation for `ProcedureBlock`.
* Added code generation routines for double, integer and
   boolean variable types.
* Added binary and unary operator code generation:
     - Supported binary operators: +, -, *, /.
     - Supported unary operators: -.
     - Assignment (=) is also supported.
* Added regex matching unit tests for LLVM code generation.
* Fixed Travis CI/builds.

fixes #451, fixes #452, fixes #456

Co-authored-by: Pramod Kumbhar <pramod.s.kumbhar@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support arithmetic binary operators Add LLVM-style differential tests Simple procedure conversion to LLVM
4 participants