mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
compiler: implement most math/bits functions
These functions can be implemented more efficiently using LLVM intrinsics. That makes them the Go equivalent of functions like __builtin_clz which are also implemented using these LLVM intrinsics. I believe the Go compiler does something very similar: IIRC it converts calls to these functions into optimal instructions for the given architecture. I tested these by running `tinygo test math/bits` after uncommenting the tests that would always fail (the *PanicZero and *PanicOverflow tests).
This commit is contained in:
committed by
Ron Evans
parent
568c2a4363
commit
464ebc4fe1
@@ -845,6 +845,11 @@ func (c *compilerContext) createPackage(irbuilder llvm.Builder, pkg *ssa.Package
|
||||
b.defineMathOp()
|
||||
continue
|
||||
}
|
||||
if ok := b.defineMathBitsIntrinsic(); ok {
|
||||
// Like a math intrinsic, the body of this function was replaced
|
||||
// with a LLVM intrinsic.
|
||||
continue
|
||||
}
|
||||
if member.Blocks == nil {
|
||||
// Try to define this as an intrinsic function.
|
||||
b.defineIntrinsicFunction()
|
||||
|
||||
Reference in New Issue
Block a user