libc complex64 support

This commit is contained in:
xushiwei
2024-06-20 10:22:35 +08:00
parent 94f61b0a0c
commit 5d957a6b7c
5 changed files with 152 additions and 10 deletions

View File

@@ -5,5 +5,8 @@ import (
)
func main() {
println("abs(3+4i):", cmplx.Abs(3+4i))
re := 3.0
im := 4.0
c := complex(re, im)
println("abs(3+4i):", cmplx.Abs(c))
}

View File

@@ -28,16 +28,22 @@ _llgo_0:
store ptr %1, ptr @__llgo_argv, align 8
call void @"github.com/goplus/llgo/internal/runtime.init"()
call void @main.init()
%2 = call double @"math/cmplx.Abs"({ double, double } { double 3.000000e+00, double 4.000000e+00 })
%3 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
%4 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %3, i32 0, i32 0
store ptr @0, ptr %4, align 8
%5 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %3, i32 0, i32 1
store i64 10, ptr %5, align 4
%6 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %3, align 8
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %6)
%2 = alloca { double, double }, align 8
%3 = getelementptr inbounds { double, double }, ptr %2, i32 0, i32 0
store double 3.000000e+00, ptr %3, align 8
%4 = getelementptr inbounds { double, double }, ptr %2, i32 0, i32 1
store double 4.000000e+00, ptr %4, align 8
%5 = load { double, double }, ptr %2, align 8
%6 = call double @"math/cmplx.Abs"({ double, double } %5)
%7 = alloca %"github.com/goplus/llgo/internal/runtime.String", align 8
%8 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %7, i32 0, i32 0
store ptr @0, ptr %8, align 8
%9 = getelementptr inbounds %"github.com/goplus/llgo/internal/runtime.String", ptr %7, i32 0, i32 1
store i64 10, ptr %9, align 4
%10 = load %"github.com/goplus/llgo/internal/runtime.String", ptr %7, align 8
call void @"github.com/goplus/llgo/internal/runtime.PrintString"(%"github.com/goplus/llgo/internal/runtime.String" %10)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 32)
call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double %2)
call void @"github.com/goplus/llgo/internal/runtime.PrintFloat"(double %6)
call void @"github.com/goplus/llgo/internal/runtime.PrintByte"(i8 10)
ret i32 0
}