-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[SPIRV] Start adding support for int128
#170798
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
+181
−13
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
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
67 changes: 67 additions & 0 deletions
67
llvm/test/CodeGen/SPIRV/extensions/SPV_ALTERA_arbitrary_precision_integers/i128-addsub.ll
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,67 @@ | ||
| ; RUN: not llc -O0 -mtriple=spirv64-unknown-unknown %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR | ||
|
|
||
| ; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_ALTERA_arbitrary_precision_integers %s -o - | FileCheck %s | ||
| ; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_ALTERA_arbitrary_precision_integers %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ; CHECK-ERROR: LLVM ERROR: OpTypeInt type with a width other than 8, 16, 32 or 64 bits requires the following SPIR-V extension: SPV_ALTERA_arbitrary_precision_integers | ||
|
|
||
| ; CHECK: OpCapability ArbitraryPrecisionIntegersALTERA | ||
| ; CHECK: OpExtension "SPV_ALTERA_arbitrary_precision_integers" | ||
| ; CHECK: OpName %[[#TestAdd:]] "test_add" | ||
| ; CHECK: OpName %[[#TestSub:]] "test_sub" | ||
| ; CHECK: %[[#Int128Ty:]] = OpTypeInt 128 0 | ||
| ; CHECK: %[[#Const64Int128:]] = OpConstant %[[#Int128Ty]] 64 0 0 0 | ||
|
|
||
| ; CHECK: %[[#TestAdd]] = OpFunction | ||
| define spir_func void @test_add(i64 %AL, i64 %AH, i64 %BL, i64 %BH, ptr %RL, ptr %RH) { | ||
| entry: | ||
| ; CHECK: {{.*}} = OpUConvert %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpUConvert %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpShiftLeftLogical %[[#Int128Ty]] {{%[0-9]+}} %[[#Const64Int128]] | ||
| ; CHECK: {{.*}} = OpBitwiseOr %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpUConvert %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpIAdd %[[#Int128Ty]] | ||
| %tmp1 = zext i64 %AL to i128 | ||
| %tmp23 = zext i64 %AH to i128 | ||
| %tmp4 = shl i128 %tmp23, 64 | ||
| %tmp5 = or i128 %tmp4, %tmp1 | ||
| %tmp67 = zext i64 %BL to i128 | ||
| %tmp89 = zext i64 %BH to i128 | ||
| %tmp11 = shl i128 %tmp89, 64 | ||
| %tmp12 = or i128 %tmp11, %tmp67 | ||
| %tmp15 = add i128 %tmp12, %tmp5 | ||
| %tmp1617 = trunc i128 %tmp15 to i64 | ||
| store i64 %tmp1617, ptr %RL | ||
| %tmp21 = lshr i128 %tmp15, 64 | ||
| %tmp2122 = trunc i128 %tmp21 to i64 | ||
| store i64 %tmp2122, ptr %RH | ||
| ret void | ||
| ; CHECK: OpFunctionEnd | ||
| } | ||
|
|
||
| ; CHECK: %[[#TestSub]] = OpFunction | ||
| define spir_func void @test_sub(i64 %AL, i64 %AH, i64 %BL, i64 %BH, ptr %RL, ptr %RH) { | ||
| entry: | ||
| ; CHECK: {{.*}} = OpUConvert %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpUConvert %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpShiftLeftLogical %[[#Int128Ty]] {{%[0-9]+}} %[[#Const64Int128]] | ||
| ; CHECK: {{.*}} = OpBitwiseOr %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpUConvert %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpISub %[[#Int128Ty]] | ||
| %tmp1 = zext i64 %AL to i128 | ||
| %tmp23 = zext i64 %AH to i128 | ||
| %tmp4 = shl i128 %tmp23, 64 | ||
| %tmp5 = or i128 %tmp4, %tmp1 | ||
| %tmp67 = zext i64 %BL to i128 | ||
| %tmp89 = zext i64 %BH to i128 | ||
| %tmp11 = shl i128 %tmp89, 64 | ||
| %tmp12 = or i128 %tmp11, %tmp67 | ||
| %tmp15 = sub i128 %tmp5, %tmp12 | ||
| %tmp1617 = trunc i128 %tmp15 to i64 | ||
| store i64 %tmp1617, ptr %RL | ||
| %tmp21 = lshr i128 %tmp15, 64 | ||
| %tmp2122 = trunc i128 %tmp21 to i64 | ||
| store i64 %tmp2122, ptr %RH | ||
| ret void | ||
| ; CHECK: OpFunctionEnd | ||
| } | ||
27 changes: 27 additions & 0 deletions
27
llvm/test/CodeGen/SPIRV/extensions/SPV_ALTERA_arbitrary_precision_integers/i128-arith.ll
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,27 @@ | ||
| ; RUN: not llc -O0 -mtriple=spirv64-unknown-unknown %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR | ||
|
|
||
| ; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_ALTERA_arbitrary_precision_integers %s -o - | FileCheck %s | ||
| ; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_ALTERA_arbitrary_precision_integers %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ; CHECK-ERROR: LLVM ERROR: OpTypeInt type with a width other than 8, 16, 32 or 64 bits requires the following SPIR-V extension: SPV_ALTERA_arbitrary_precision_integers | ||
|
|
||
| ; CHECK: OpCapability ArbitraryPrecisionIntegersALTERA | ||
| ; CHECK: OpExtension "SPV_ALTERA_arbitrary_precision_integers" | ||
| ; CHECK: OpName %[[#Foo:]] "foo" | ||
| ; CHECK: %[[#Int128Ty:]] = OpTypeInt 128 0 | ||
|
|
||
| ; CHECK: %[[#Foo]] = OpFunction | ||
| define i64 @foo(i64 %x, i64 %y, i32 %amt) { | ||
| ; CHECK: {{.*}} = OpUConvert %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpSConvert %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpBitwiseOr %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpUConvert %[[#Int128Ty]] | ||
| ; CHECK: {{.*}} = OpShiftRightLogical %[[#Int128Ty]] | ||
| %tmp0 = zext i64 %x to i128 | ||
| %tmp1 = sext i64 %y to i128 | ||
| %tmp2 = or i128 %tmp0, %tmp1 | ||
| %tmp7 = zext i32 13 to i128 | ||
| %tmp3 = lshr i128 %tmp2, %tmp7 | ||
| %tmp4 = trunc i128 %tmp3 to i64 | ||
| ret i64 %tmp4 | ||
| } |
27 changes: 27 additions & 0 deletions
27
...est/CodeGen/SPIRV/extensions/SPV_ALTERA_arbitrary_precision_integers/i128-switch-lower.ll
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,27 @@ | ||
| ; RUN: not llc -O0 -mtriple=spirv64-unknown-unknown %s -o %t.spvt 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR | ||
|
|
||
| ; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_ALTERA_arbitrary_precision_integers %s -o - | FileCheck %s | ||
| ; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_ALTERA_arbitrary_precision_integers %s -o - -filetype=obj | spirv-val %} | ||
|
|
||
| ; CHECK-ERROR: LLVM ERROR: OpTypeInt type with a width other than 8, 16, 32 or 64 bits requires the following SPIR-V extension: SPV_ALTERA_arbitrary_precision_integers | ||
|
|
||
| ; CHECK: OpCapability ArbitraryPrecisionIntegersALTERA | ||
| ; CHECK: OpExtension "SPV_ALTERA_arbitrary_precision_integers" | ||
| ; CHECK: OpName %[[#Test:]] "test" | ||
| ; CHECK: OpName %[[#Exit:]] "exit" | ||
| ; CHECK: %[[#Int128Ty:]] = OpTypeInt 128 0 | ||
| ; CHECK: %[[#UndefInt128:]] = OpUndef %[[#Int128Ty]] | ||
|
|
||
| ; CHECK: %[[#Test]] = OpFunction | ||
| define void @test() { | ||
| entry: | ||
| ; CHECK: OpSwitch %[[#UndefInt128]] %[[#Exit]] 0 0 3 0 %[[#Exit]] 0 0 5 0 %[[#Exit]] 0 0 4 0 %[[#Exit]] 0 0 8 0 %[[#Exit]] | ||
| switch i128 poison, label %exit [ | ||
| i128 55340232221128654848, label %exit | ||
| i128 92233720368547758080, label %exit | ||
| i128 73786976294838206464, label %exit | ||
| i128 147573952589676412928, label %exit | ||
| ] | ||
| exit: | ||
| unreachable | ||
| } |
1 change: 1 addition & 0 deletions
1
llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-but-one.ll
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
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.
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.
Just curious (potentially thinking about, what we might be missing): what happens with i126 scalars?
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.
Good question! Today it fails opaquely, with
Unsupported integer width. With this patch it'd either pass if the required extension is present, or fail at module analysis with a slightly more informative message around needing to add the extension.