forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DirectX] Add trig intrinsics and link them with DXIL backend (llvm#9…
…5968) This change is part of this proposal: https://discourse.llvm.org/t/rfc-all-the-math-intrinsics/78294 This is part 1 of 4 PRs. It sets the ground work for adding the intrinsics. Add DXIL Lower for `acos`, `asin`, `atan`, `cosh`, `sinh`, and `tanh` llvm#70079 llvm#70080 llvm#70081 llvm#70083 llvm#70084 llvm#95966
- Loading branch information
Showing
15 changed files
with
427 additions
and
0 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
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,20 @@ | ||
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for acos are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 15, float %{{.*}}) | ||
%elt.acos = call float @llvm.acos.f32(float %a) | ||
ret float %elt.acos | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 15, half %{{.*}}) | ||
%elt.acos = call half @llvm.acos.f16(half %a) | ||
ret half %elt.acos | ||
} | ||
|
||
declare half @llvm.acos.f16(half) | ||
declare float @llvm.acos.f32(float) |
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,10 @@ | ||
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s | ||
|
||
; DXIL operation acos does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload | ||
|
||
define noundef double @acos_double(double noundef %a) { | ||
entry: | ||
%1 = call double @llvm.acos.f64(double %a) | ||
ret double %1 | ||
} |
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,20 @@ | ||
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for asin are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 16, float %{{.*}}) | ||
%elt.asin = call float @llvm.asin.f32(float %a) | ||
ret float %elt.asin | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 16, half %{{.*}}) | ||
%elt.asin = call half @llvm.asin.f16(half %a) | ||
ret half %elt.asin | ||
} | ||
|
||
declare half @llvm.asin.f16(half) | ||
declare float @llvm.asin.f32(float) |
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,10 @@ | ||
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s | ||
|
||
; DXIL operation asin does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload | ||
|
||
define noundef double @asin_double(double noundef %a) { | ||
entry: | ||
%1 = call double @llvm.asin.f64(double %a) | ||
ret double %1 | ||
} |
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,20 @@ | ||
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for atan are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 17, float %{{.*}}) | ||
%elt.atan = call float @llvm.atan.f32(float %a) | ||
ret float %elt.atan | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 17, half %{{.*}}) | ||
%elt.atan = call half @llvm.atan.f16(half %a) | ||
ret half %elt.atan | ||
} | ||
|
||
declare half @llvm.atan.f16(half) | ||
declare float @llvm.atan.f32(float) |
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,10 @@ | ||
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s | ||
|
||
; DXIL operation atan does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload | ||
|
||
define noundef double @atan_double(double noundef %a) { | ||
entry: | ||
%1 = call double @llvm.atan.f64(double %a) | ||
ret double %1 | ||
} |
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,20 @@ | ||
; RUN: opt -S -dxil-op-lower < %s | FileCheck %s | ||
|
||
; Make sure dxil operation function calls for cosh are generated for float and half. | ||
|
||
define noundef float @tan_float(float noundef %a) { | ||
entry: | ||
; CHECK:call float @dx.op.unary.f32(i32 18, float %{{.*}}) | ||
%elt.cosh = call float @llvm.cosh.f32(float %a) | ||
ret float %elt.cosh | ||
} | ||
|
||
define noundef half @tan_half(half noundef %a) { | ||
entry: | ||
; CHECK:call half @dx.op.unary.f16(i32 18, half %{{.*}}) | ||
%elt.cosh = call half @llvm.cosh.f16(half %a) | ||
ret half %elt.cosh | ||
} | ||
|
||
declare half @llvm.cosh.f16(half) | ||
declare float @llvm.cosh.f32(float) |
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,10 @@ | ||
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s | ||
|
||
; DXIL operation cosh does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload | ||
|
||
define noundef double @cosh_double(double noundef %a) { | ||
entry: | ||
%1 = call double @llvm.cosh.f64(double %a) | ||
ret double %1 | ||
} |
Oops, something went wrong.