2015-08-11 10:45:15 +08:00
|
|
|
; RUN: llc < %s -asm-verbose=false | FileCheck %s
|
|
|
|
|
|
|
|
; Test that basic 32-bit floating-point operations assemble as expected.
|
|
|
|
|
2015-08-20 04:30:20 +08:00
|
|
|
target datalayout = "e-p:32:32-i64:64-n32:64-S128"
|
2015-08-11 10:45:15 +08:00
|
|
|
target triple = "wasm32-unknown-unknown"
|
|
|
|
|
|
|
|
declare float @llvm.fabs.f32(float)
|
|
|
|
declare float @llvm.copysign.f32(float, float)
|
|
|
|
declare float @llvm.sqrt.f32(float)
|
2015-08-25 02:23:13 +08:00
|
|
|
declare float @llvm.ceil.f32(float)
|
|
|
|
declare float @llvm.floor.f32(float)
|
|
|
|
declare float @llvm.trunc.f32(float)
|
|
|
|
declare float @llvm.nearbyint.f32(float)
|
|
|
|
declare float @llvm.rint.f32(float)
|
2015-08-11 10:45:15 +08:00
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fadd32:
|
|
|
|
; CHECK-NEXT: .param f32{{$}}
|
|
|
|
; CHECK-NEXT: .param f32{{$}}
|
|
|
|
; CHECK-NEXT: .result f32{{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: .local f32, f32, f32{{$}}
|
2015-11-07 05:26:50 +08:00
|
|
|
; CHECK-NEXT: get_local push, 1{{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 2, pop{{$}}
|
2015-11-07 05:26:50 +08:00
|
|
|
; CHECK-NEXT: get_local push, 0{{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 3, pop{{$}}
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK-NEXT: add push, (get_local 3), (get_local 2){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 4, pop{{$}}
|
|
|
|
; CHECK-NEXT: return (get_local 4){{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @fadd32(float %x, float %y) {
|
|
|
|
%a = fadd float %x, %y
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fsub32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: sub push, (get_local 3), (get_local 2){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 4, pop{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @fsub32(float %x, float %y) {
|
|
|
|
%a = fsub float %x, %y
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fmul32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: mul push, (get_local 3), (get_local 2){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 4, pop{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @fmul32(float %x, float %y) {
|
|
|
|
%a = fmul float %x, %y
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fdiv32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: div push, (get_local 3), (get_local 2){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 4, pop{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @fdiv32(float %x, float %y) {
|
|
|
|
%a = fdiv float %x, %y
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fabs32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: abs push, (get_local 1){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 2, pop{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @fabs32(float %x) {
|
|
|
|
%a = call float @llvm.fabs.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: fneg32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: neg push, (get_local 1){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 2, pop{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @fneg32(float %x) {
|
|
|
|
%a = fsub float -0., %x
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: copysign32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: copysign push, (get_local 3), (get_local 2){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 4, pop{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @copysign32(float %x, float %y) {
|
|
|
|
%a = call float @llvm.copysign.f32(float %x, float %y)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: sqrt32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: sqrt push, (get_local 1){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 2, pop{{$}}
|
2015-08-11 10:45:15 +08:00
|
|
|
define float @sqrt32(float %x) {
|
|
|
|
%a = call float @llvm.sqrt.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
2015-08-25 02:23:13 +08:00
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: ceil32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: ceil push, (get_local 1){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 2, pop{{$}}
|
2015-08-25 02:23:13 +08:00
|
|
|
define float @ceil32(float %x) {
|
|
|
|
%a = call float @llvm.ceil.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: floor32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: floor push, (get_local 1){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 2, pop{{$}}
|
2015-08-25 02:23:13 +08:00
|
|
|
define float @floor32(float %x) {
|
|
|
|
%a = call float @llvm.floor.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: trunc32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: trunc push, (get_local 1){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 2, pop{{$}}
|
2015-08-25 02:23:13 +08:00
|
|
|
define float @trunc32(float %x) {
|
|
|
|
%a = call float @llvm.trunc.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: nearest32:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: nearest push, (get_local 1){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 2, pop{{$}}
|
2015-09-26 09:09:44 +08:00
|
|
|
define float @nearest32(float %x) {
|
2015-08-25 02:23:13 +08:00
|
|
|
%a = call float @llvm.nearbyint.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|
|
|
|
|
2015-10-06 08:27:55 +08:00
|
|
|
; CHECK-LABEL: nearest32_via_rint:
|
2015-11-07 03:45:01 +08:00
|
|
|
; CHECK: nearest push, (get_local 1){{$}}
|
2015-10-16 08:53:49 +08:00
|
|
|
; CHECK-NEXT: set_local 2, pop{{$}}
|
2015-09-26 09:09:44 +08:00
|
|
|
define float @nearest32_via_rint(float %x) {
|
2015-08-25 02:23:13 +08:00
|
|
|
%a = call float @llvm.rint.f32(float %x)
|
|
|
|
ret float %a
|
|
|
|
}
|