compiler: move LLVM math builtin support into the compiler

This simplifies src/runtime/math.go, which I eventually want to remove
entirely by moving the given functionality into the compiler.
This commit is contained in:
Ayke van Laethem
2021-08-06 15:49:02 +02:00
committed by Ron Evans
parent ca7c849da3
commit 58565b42cc
7 changed files with 138 additions and 37 deletions
+6 -1
View File
@@ -23,7 +23,7 @@ import (
// Version of the compiler pacakge. Must be incremented each time the compiler
// package changes in a way that affects the generated LLVM module.
// This version is independent of the TinyGo version number.
const Version = 12 // last change: implement syscall.rawSyscallNoError
const Version = 13 // last change: implement LLVM math builtins in the compiler
func init() {
llvm.InitializeAllTargets()
@@ -1298,6 +1298,11 @@ func (b *builder) createFunctionCall(instr *ssa.CallCommon) (llvm.Value, error)
return b.createMemoryCopyCall(fn, instr.Args)
case name == "runtime.memzero":
return b.createMemoryZeroCall(instr.Args)
case name == "math.Ceil" || name == "math.Floor" || name == "math.Sqrt" || name == "math.Trunc":
result, ok := b.createMathOp(instr)
if ok {
return result, nil
}
case name == "device.Asm" || name == "device/arm.Asm" || name == "device/arm64.Asm" || name == "device/avr.Asm" || name == "device/riscv.Asm":
return b.createInlineAsm(instr.Args)
case name == "device.AsmFull" || name == "device/arm.AsmFull" || name == "device/arm64.AsmFull" || name == "device/avr.AsmFull" || name == "device/riscv.AsmFull":