This repository has been archived by the owner on Oct 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Translation of LLVM intrinsics (#185)
An LLVM intrinsic should not be transalated to SPIRV as a function call. Either it's semantics is represented via SPIRV instruction(s) or an error is reported.
- Loading branch information
1 parent
c370052
commit 73e65fc
Showing
5 changed files
with
206 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
; Translator should not translate llvm intrinsic calls straight forward. | ||
; It either represnts intrinsic's semantics with SPIRV instruction(s), or | ||
; reports an error. | ||
; XFAIL: * | ||
; RUN: llvm-as %s -o %t.bc | ||
; RUN: llvm-spirv %t.bc | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64" | ||
|
||
; Function Attrs: nounwind | ||
define spir_func void @foo(float %a, float %b, float %c) #0 { | ||
entry: | ||
%0 = call float @llvm.fma.f32(float %a, float %b, float %c) | ||
ret void | ||
} | ||
|
||
; Function Attrs: nounwind readnone | ||
declare float @llvm.fma.f32(float, float, float) #1 | ||
|
||
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } | ||
attributes #1 = { nounwind readnone } | ||
|
||
!opencl.enable.FP_CONTRACT = !{} | ||
!opencl.spir.version = !{!0} | ||
!opencl.ocl.version = !{!1} | ||
!opencl.used.extensions = !{!2} | ||
!opencl.used.optional.core.features = !{!3} | ||
!opencl.compiler.options = !{!2} | ||
|
||
!0 = !{i32 1, i32 2} | ||
!1 = !{i32 2, i32 0} | ||
!2 = !{} | ||
!3 = !{!"cl_doubles"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
; RUN: llvm-as %s -o %t.bc | ||
; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s | ||
|
||
; CHECK-NOT: llvm.fmuladd | ||
|
||
; CHECK: TypeFloat [[f32:[0-9]+]] 32 | ||
; CHECK: TypeFloat [[f64:[0-9]+]] 64 | ||
|
||
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir64" | ||
|
||
; Function Attrs: nounwind | ||
define spir_func void @foo(float %a, float %b, float %c, double %x, double %y, double %z) #0 { | ||
entry: | ||
%0 = call float @llvm.fmuladd.f32(float %a, float %b, float %c) | ||
; CHECK: FMul [[f32]] [[mul32:[0-9]+]] {{[0-9]+}} {{[0-9]+}} | ||
; CHECK-NEXT: FAdd [[f32]] {{[0-9]+}} [[mul32]] {{[0-9]+}} | ||
%1 = call double @llvm.fmuladd.f64(double %x, double %y, double %z) | ||
; CHECK: FMul [[f64]] [[mul64:[0-9]+]] {{[0-9]+}} {{[0-9]+}} | ||
; CHECK-NEXT: FAdd [[f64]] {{[0-9]+}} [[mul64]] {{[0-9]+}} | ||
ret void | ||
} | ||
|
||
; Function Attrs: nounwind readnone | ||
declare float @llvm.fmuladd.f32(float, float, float) #1 | ||
|
||
; Function Attrs: nounwind readnone | ||
declare double @llvm.fmuladd.f64(double, double, double) #1 | ||
|
||
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } | ||
attributes #1 = { nounwind readnone } | ||
|
||
!opencl.enable.FP_CONTRACT = !{} | ||
!opencl.spir.version = !{!0} | ||
!opencl.ocl.version = !{!1} | ||
!opencl.used.extensions = !{!2} | ||
!opencl.used.optional.core.features = !{!3} | ||
!opencl.compiler.options = !{!2} | ||
|
||
!0 = !{i32 1, i32 2} | ||
!1 = !{i32 2, i32 0} | ||
!2 = !{} | ||
!3 = !{!"cl_doubles"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
; RUN: llvm-as %s -o %t.bc | ||
; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s | ||
|
||
; CHECK-NOT: llvm.memset | ||
|
||
; CHECK: TypeInt [[int32:[0-9]+]] 32 | ||
; CHECK: Constant [[int32]] [[fiftieen:[0-9]+]] 15 | ||
; CHECK: TypeArray [[int32x15:[0-9]+]] [[int32]] [[fiftieen]] | ||
; CHECK: TypePointer [[int32x15Ptr:[0-9]+]] 7 [[int32x15]] | ||
; CHECK: ConstantNull [[int32x15]] [[ConstantNull:[0-9]+]] | ||
|
||
; CHECK: Variable [[int32x15Ptr:[0-9]+]] [[mem:[0-9]+]] 7 | ||
; CHECK: Store [[mem]] [[ConstantNull]] | ||
|
||
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64" | ||
target triple = "spir" | ||
|
||
; Function Attrs: nounwind | ||
define spir_func void @test() #0 { | ||
entry: | ||
%mem = alloca [15 x i32], align 4 | ||
%0 = bitcast [15 x i32]* %mem to i8* | ||
call void @llvm.memset.p0i8.i32(i8* %0, i8 0, i32 60, i32 4, i1 false) | ||
ret void | ||
} | ||
|
||
; Function Attrs: nounwind | ||
declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i32, i1) #1 | ||
|
||
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } | ||
attributes #1 = { nounwind } | ||
|
||
!opencl.enable.FP_CONTRACT = !{} | ||
!opencl.spir.version = !{!0} | ||
!opencl.ocl.version = !{!1} | ||
!opencl.used.extensions = !{!2} | ||
!opencl.used.optional.core.features = !{!2} | ||
!opencl.compiler.options = !{!2} | ||
|
||
!0 = !{i32 1, i32 2} | ||
!1 = !{i32 2, i32 0} | ||
!2 = !{} |