-
-
Notifications
You must be signed in to change notification settings - Fork 5
use llir/llvm@v0.3.0-pre2 for code generation #115
Conversation
Codecov Report
@@ Coverage Diff @@
## llir #115 +/- ##
==========================================
- Coverage 73.46% 72.44% -1.03%
==========================================
Files 5 5
Lines 196 196
==========================================
- Hits 144 142 -2
- Misses 52 53 +1
- Partials 0 1 +1
Continue to review full report at Codecov.
|
codegen/codegen_test.go
Outdated
@@ -36,5 +36,6 @@ func TestBinaryFunction(t *testing.T) { | |||
}, | |||
}, | |||
) | |||
builder.NewRet(v) |
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.
Note, this ret instruction was added in the PR.
codegen/codegen.go
Outdated
newFunctionBuilder.SetInsertPointAtEnd(block) | ||
newFn := c.mod.NewFunc(binding.Name, retT, params...) | ||
block := newFn.NewBlock("") | ||
newFunctionBuilder := block |
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.
newFnBuilder := newFn.NewBlock("")
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.
newFnBuilder := newFn.NewBlock("")
Done.
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.
I made the update, but after thinking about it further, there is a benefit with having the basic block created explicitly (as was done in the original code). The reason is that you may want to update how the builder works, right now, it always uses SetInsertPointAtEnd
by default.
In particular, I would imagine that the type Builder interface in builder.go would be replaced with a concrete builder implementation that allows for more flexible control over insertion points for instructions.
This is just a suggestion however, and you can update the code at that time, should the need arise.
Cheers,
Robin
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 the explanation, I'm also thinking why not use concrete type XD.
* use llir/llvm@v0.3.0-pre2 for code generation (#115) * use llir/llvm@v0.3.0-pre2 for code generation * use NewFunc instead of NewFunction * update go.mod to latest version of llir/llvm * codegen: simplify use of builder based on feedback from @dannypsnl * test: remove c-binding go-llvm * fix: count function call type by expression At least not hard code
As an experiment, use the latest version of llir/llvm for code generation.
codegen
test case output:Updates #5.
P.S. the test case was also updated to include a
ret
instruction for the@main
function.