-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[DirectX][NFC] Model precise overload type specification of DXIL Ops #83917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bharadwajy
merged 1 commit into
llvm:main
from
bharadwajy:dxil_td/precise_dxil_type_spec
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s | ||
|
||
; DXIL operation exp2 does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload | ||
|
||
define noundef double @exp2_double(double noundef %a) #0 { | ||
entry: | ||
%a.addr = alloca double, align 8 | ||
store double %a, ptr %a.addr, align 8 | ||
%0 = load double, ptr %a.addr, align 8 | ||
%elt.exp2 = call double @llvm.exp2.f64(double %0) | ||
ret double %elt.exp2 | ||
} |
This file contains hidden or 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 hidden or 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,14 @@ | ||
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s | ||
|
||
; DXIL operation frac does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload Type | ||
|
||
; Function Attrs: noinline nounwind optnone | ||
define noundef double @frac_double(double noundef %a) #0 { | ||
entry: | ||
%a.addr = alloca double, align 8 | ||
store double %a, ptr %a.addr, align 8 | ||
%0 = load double, ptr %a.addr, align 8 | ||
%dx.frac = call double @llvm.dx.frac.f64(double %0) | ||
ret double %dx.frac | ||
} |
This file contains hidden or 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,13 @@ | ||
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s | ||
|
||
; This test is expected to fail with the following error | ||
; CHECK: LLVM ERROR: Invalid Overload Type | ||
|
||
define noundef double @round_double(double noundef %a) #0 { | ||
entry: | ||
%a.addr = alloca double, align 8 | ||
store double %a, ptr %a.addr, align 8 | ||
%0 = load double, ptr %a.addr, align 8 | ||
%elt.round = call double @llvm.round.f64(double %0) | ||
ret double %elt.round | ||
} |
This file contains hidden or 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 hidden or 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,14 @@ | ||
; RUN: not opt -S -dxil-op-lower %s 2>&1 | FileCheck %s | ||
|
||
; DXIL operation sin does not support double overload type | ||
; CHECK: LLVM ERROR: Invalid Overload | ||
|
||
define noundef double @sin_double(double noundef %a) #0 { | ||
entry: | ||
%a.addr = alloca double, align 8 | ||
store double %a, ptr %a.addr, align 8 | ||
%0 = load double, ptr %a.addr, align 8 | ||
%1 = call double @llvm.sin.f64(double %0) | ||
ret double %1 | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For frac we created our own intrinsic. Do we have to duplicate the type definition or could we just update in intrinsicsDirectx.td and then inherit type? Since in this case its our own intrinsic could we just prevent generation of double instead of erroring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type used is
llvm_halforfloat_ty
- which is defined inDXIL.td
. Using it to specifyint_dx_frac
will require the type definition to be moved toIntrinsicsDirectX.td
. I also believe, as a result, the TableGen backends need to be taught to handle that type appropriately - all of which can be done but not (yet) sure of the impact (and need) in the standard Tablegen backends since definitions inIntrisicsDirectX.td
appear to be globally available.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More relevantly, the valid overload type of DirectX intrinsic
int_dx_frac
, viz.,llvm_anyfloat_ty
, which is float of any format and hence includes any scalar and vector floating-point types. OTOH, valid overload type for DXIL operationFrac
that maps toint_dx_frac
is one of the two scalar typeshalf
anddouble
- denoted byllvm_halforfloat_ty
defined inDXIL.td
, to represent the more restrictive overload type. So, inheriting the type specification ofint_dx_frac
forFrac
would not accurately model valid overload types ofFrac
.