-
Notifications
You must be signed in to change notification settings - Fork 1.6k
cranelift: Add support for parsing i128 data values #3351
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
Merged
Changes from all commits
Commits
Show all changes
3 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
109 changes: 46 additions & 63 deletions
109
cranelift/filetests/filetests/runtests/i128-arithmetic.clif
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 |
|---|---|---|
| @@ -1,74 +1,57 @@ | ||
| test interpret | ||
| test run | ||
| set enable_llvm_abi_extensions=true | ||
| target aarch64 | ||
| ; target s390x TODO: Not yet implemented on s390x | ||
| target x86_64 machinst | ||
|
|
||
| ; TODO: Cleanup these tests when we have native support for i128 immediates in CLIF's parser | ||
|
|
||
| function %add_i128(i64, i64, i64, i64) -> i64, i64 { | ||
| block0(v0: i64,v1: i64,v2: i64,v3: i64): | ||
| v4 = iconcat v0, v1 | ||
| v5 = iconcat v2, v3 | ||
|
|
||
| v6 = iadd v4, v5 | ||
|
|
||
| v7, v8 = isplit v6 | ||
| return v7, v8 | ||
| function %add_i128(i128, i128) -> i128 { | ||
| block0(v0: i128,v1: i128): | ||
| v2 = iadd v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %add_i128(0, 0, 0, 0) == [0, 0] | ||
| ; run: %add_i128(0, -1, -1, 0) == [-1, -1] | ||
| ; run: %add_i128(1, 0, 0, 0) == [1, 0] | ||
| ; run: %add_i128(1, 0, 1, 0) == [2, 0] | ||
| ; run: %add_i128(1, 0, -1, -1) == [0, 0] | ||
| ; run: %add_i128(-1, 0, 1, 0) == [0, 1] | ||
|
|
||
| ; run: %add_i128(0x01234567_89ABCDEF, 0x01234567_89ABCDEF, 0xFEDCBA98_76543210, 0xFEDCBA98_76543210) == [-1, -1] | ||
| ; run: %add_i128(0x06060606_06060606, 0xA00A00A0_0A00A00A, 0x30303030_30303030, 0x0BB0BB0B_B0BB0BB0) == [0x36363636_36363636, 0xABBABBAB_BABBABBA] | ||
| ; run: %add_i128(0xC0FFEEEE_C0FFEEEE, 0xC0FFEEEE_C0FFEEEE, 0x1DCB1111_1DCB1111, 0x1DCB1111_1DCB1111) == [0xDECAFFFF_DECAFFFF, 0xDECAFFFF_DECAFFFF] | ||
|
|
||
| function %sub_i128(i64, i64, i64, i64) -> i64, i64 { | ||
| block0(v0: i64,v1: i64,v2: i64,v3: i64): | ||
| v4 = iconcat v0, v1 | ||
| v5 = iconcat v2, v3 | ||
|
|
||
| v6 = isub v4, v5 | ||
|
|
||
| v7, v8 = isplit v6 | ||
| return v7, v8 | ||
| ; run: %add_i128(0, 0) == 0 | ||
| ; run: %add_i128(1, 0) == 1 | ||
| ; run: %add_i128(1, 1) == 2 | ||
| ; run: %add_i128(1, -1) == 0 | ||
| ; run: %add_i128(0xFFFFFFFF_FFFFFFFF_00000000_00000000, 0x00000000_00000000_FFFFFFFF_FFFFFFFF) == -1 | ||
| ; run: %add_i128(0x00000000_00000000_FFFFFFFF_FFFFFFFF, 1) == 0x00000000_00000001_00000000_00000000 | ||
|
|
||
| ; run: %add_i128(0x01234567_89ABCDEF_01234567_89ABCDEF, 0xFEDCBA98_76543210_FEDCBA98_76543210) == -1 | ||
| ; run: %add_i128(0x06060606_06060606_A00A00A0_0A00A00A, 0x30303030_30303030_0BB0BB0B_B0BB0BB0) == 0x36363636_36363636_ABBABBAB_BABBABBA | ||
| ; run: %add_i128(0xC0FFEEEE_C0FFEEEE_C0FFEEEE_C0FFEEEE, 0x1DCB1111_1DCB1111_1DCB1111_1DCB1111) == 0xDECAFFFF_DECAFFFF_DECAFFFF_DECAFFFF | ||
|
|
||
|
|
||
| function %sub_i128(i128, i128) -> i128 { | ||
| block0(v0: i128,v1: i128): | ||
| v2 = isub v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %sub_i128(0, 0, 0, 0) == [0, 0] | ||
| ; run: %sub_i128(1, 0, 1, 0) == [0, 0] | ||
| ; run: %sub_i128(1, 0, 0, 0) == [1, 0] | ||
| ; run: %sub_i128(0, 0, 1, 0) == [-1, -1] | ||
| ; run: %sub_i128(0, 0, -1, -1) == [1, 0] | ||
|
|
||
| ; run: %sub_i128(-1, -1, 0xFEDCBA98_76543210, 0xFEDCBA98_76543210) == [0x01234567_89ABCDEF, 0x01234567_89ABCDEF] | ||
| ; run: %sub_i128(0x36363636_36363636, 0xABBABBAB_BABBABBA, 0x30303030_30303030, 0x0BB0BB0B_B0BB0BB0) == [0x06060606_06060606, 0xA00A00A0_0A00A00A] | ||
| ; run: %sub_i128(0xDECAFFFF_DECAFFFF, 0xDECAFFFF_DECAFFFF, 0x1DCB1111_1DCB1111, 0x1DCB1111_1DCB1111) == [0xC0FFEEEE_C0FFEEEE, 0xC0FFEEEE_C0FFEEEE] | ||
| ; run: %sub_i128(0, 0) == 0 | ||
| ; run: %sub_i128(1, 1) == 0 | ||
| ; run: %sub_i128(1, 0) == 1 | ||
| ; run: %sub_i128(0, 1) == -1 | ||
| ; run: %sub_i128(0, -1) == 1 | ||
|
|
||
| ; run: %sub_i128(-1, 0xFEDCBA98_76543210_FEDCBA98_76543210) == 0x01234567_89ABCDEF_01234567_89ABCDEF | ||
| ; run: %sub_i128(0x36363636_36363636_ABBABBAB_BABBABBA, 0x30303030_30303030_0BB0BB0B_B0BB0BB0) == 0x06060606_06060606_A00A00A0_0A00A00A | ||
| ; run: %sub_i128(0xDECAFFFF_DECAFFFF_DECAFFFF_DECAFFFF, 0x1DCB1111_1DCB1111_1DCB1111_1DCB1111) == 0xC0FFEEEE_C0FFEEEE_C0FFEEEE_C0FFEEEE | ||
|
|
||
| function %mul_i128(i64, i64, i64, i64) -> i64, i64 { | ||
| block0(v0: i64,v1: i64,v2: i64,v3: i64): | ||
| v4 = iconcat v0, v1 | ||
| v5 = iconcat v2, v3 | ||
|
|
||
| v6 = imul v4, v5 | ||
|
|
||
| v7, v8 = isplit v6 | ||
| return v7, v8 | ||
| function %mul_i128(i128, i128) -> i128 { | ||
| block0(v0: i128,v1: i128): | ||
| v2 = imul v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %mul_i128(0, 0, 0, 0) == [0, 0] | ||
| ; run: %mul_i128(1, 0, 1, 0) == [1, 0] | ||
| ; run: %mul_i128(1, 0, 0, 0) == [0, 0] | ||
| ; run: %mul_i128(0, 0, 1, 0) == [0, 0] | ||
| ; run: %mul_i128(2, 0, 1, 0) == [2, 0] | ||
| ; run: %mul_i128(2, 0, 2, 0) == [4, 0] | ||
| ; run: %mul_i128(1, 0, -1, -1) == [-1, -1] | ||
| ; run: %mul_i128(2, 0, -1, -1) == [-2, -1] | ||
|
|
||
| ; run: %mul_i128(0x01010101_01010101, 0x01010101_01010101, 13, 0) == [0x0D0D0D0D_0D0D0D0D, 0x0D0D0D0D_0D0D0D0D] | ||
| ; run: %mul_i128(13, 0, 0x01010101_01010101, 0x01010101_01010101) == [0x0D0D0D0D_0D0D0D0D, 0x0D0D0D0D_0D0D0D0D] | ||
| ; run: %mul_i128(0x00000000_01234567, 0x89ABCDEF_00000000, 0x00000000_FEDCBA98, 0x76543210_00000000) == [0x0121FA00_23E20B28, 0xE2946058_00000000] | ||
| ; run: %mul_i128(0xC0FFEEEE_C0FFEEEE, 0xC0FFEEEE_C0FFEEEE, 0xDECAFFFF_DECAFFFF, 0xDECAFFFF_DECAFFFF) == [0xDB6B1E48_19BA1112, 0x5ECD38B5_9D1C2B7E] | ||
| ; run: %mul_i128(0xC0FFEEEE_C0FFEEEE, 0xC0FFEEEE_C0FFEEEE, 0xDECAFFFF_DECAFFFF, 0xDECAFFFF_DECAFFFF) == [0xDB6B1E48_19BA1112, 0x5ECD38B5_9D1C2B7E] | ||
| ; run: %mul_i128(0, 0) == 0 | ||
| ; run: %mul_i128(1, 1) == 1 | ||
| ; run: %mul_i128(1, 0) == 0 | ||
| ; run: %mul_i128(0, 1) == 0 | ||
| ; run: %mul_i128(2, 1) == 2 | ||
| ; run: %mul_i128(2, 2) == 4 | ||
| ; run: %mul_i128(1, -1) == -1 | ||
| ; run: %mul_i128(2, -1) == -2 | ||
|
|
||
| ; run: %mul_i128(0x01010101_01010101_01010101_01010101, 13) == 0x0D0D0D0D_0D0D0D0D_0D0D0D0D_0D0D0D0D | ||
| ; run: %mul_i128(13, 0x01010101_01010101_01010101_01010101) == 0x0D0D0D0D_0D0D0D0D_0D0D0D0D_0D0D0D0D | ||
| ; run: %mul_i128(0x00000000_01234567_89ABCDEF_00000000, 0x00000000_FEDCBA98_76543210_00000000) == 0x2236D88F_E5618CF0_00000000_00000000 | ||
| ; run: %mul_i128(0xC0FFEEEE_C0FFEEEE_C0FFEEEE_C0FFEEEE, 0xDECAFFFF_DECAFFFF_DECAFFFF_DECAFFFF) == 0x5ECD38B5_9D1C2B7E_DB6B1E48_19BA1112 |
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 @@ | ||
| test run | ||
| target aarch64 | ||
|
|
||
| function %band_not_i128(i128, i128) -> i128 { | ||
| block0(v0: i128, v1: i128): | ||
| v2 = band_not v0, v1 | ||
| return v2 | ||
| } | ||
| ; run: %band_not_i128(0, 0) == 0 | ||
| ; run: %band_not_i128(-1, 0) == -1 | ||
| ; run: %band_not_i128(-1, -1) == 0 | ||
| ; run: %band_not_i128(-1, 0xFFFFFFFF_FFFFFFFF_00000000_00000000) == 0x00000000_00000000_FFFFFFFF_FFFFFFFF | ||
| ; run: %band_not_i128(0xFEDCBA98_76543210_01234567_89ABCDEF, 0x01234567_89ABCDEF_FEDCBA98_76543210) == 0xFEDCBA98_76543210_01234567_89ABCDEF | ||
| ; run: %band_not_i128(0xFEEEFFFF_FEEEFFFF_F1FFFEFE_F1FFFEFE, 0x20240000_20240000_31001010_31001010) == 0xDECAFFFF_DECAFFFF_C0FFEEEE_C0FFEEEE |
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 |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| test run | ||
| set enable_llvm_abi_extensions=true | ||
| target aarch64 | ||
| target x86_64 machinst | ||
|
|
||
| function %bint_b8_i128() -> i64, i64 { | ||
| function %bint_b8_i128() -> i128 { | ||
| block0: | ||
| v0 = bconst.b8 true | ||
| v1 = bint.i128 v0 | ||
| v2, v3 = isplit.i128 v1 | ||
| return v2, v3 | ||
| return v1 | ||
| } | ||
| ; run: %bint_b8_i128() == [1, 0] | ||
| ; run: %bint_b8_i128() == 1 |
24 changes: 0 additions & 24 deletions
24
cranelift/filetests/filetests/runtests/i128-bitops-cls.clif
This file was deleted.
Oops, something went wrong.
97 changes: 41 additions & 56 deletions
97
cranelift/filetests/filetests/runtests/i128-bitops-count.clif
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 |
|---|---|---|
| @@ -1,63 +1,48 @@ | ||
| test run | ||
| set enable_llvm_abi_extensions=true | ||
| target aarch64 | ||
| ; target s390x TODO: Not yet implemented on s390x | ||
| target x86_64 machinst | ||
|
|
||
| function %ctz_i128(i64, i64) -> i64 { | ||
| block0(v0: i64, v1: i64): | ||
| v2 = iconcat v0, v1 | ||
|
|
||
| v3 = ctz v2 | ||
|
|
||
| v4, v5 = isplit v3 | ||
| v6 = iadd v4, v5 | ||
| return v6 | ||
| function %ctz_i128(i128) -> i128 { | ||
| block0(v0: i128): | ||
| v1 = ctz v0 | ||
| return v1 | ||
| } | ||
| ; run: %ctz_i128(0x00000000_00000000, 0x00000000_00000000) == 128 | ||
| ; run: %ctz_i128(0xFFFFFFFF_FFFFFFFF, 0x00000000_00000000) == 0 | ||
| ; run: %ctz_i128(0x00000000_00000000, 0xFFFFFFFF_FFFFFFFF) == 64 | ||
| ; run: %ctz_i128(0xFFFFFFFF_FFFFFFFF, 0xFFFFFFFF_FFFFFFFF) == 0 | ||
| ; run: %ctz_i128(0xFFFFFFFF_00000000, 0xF0000000_00000000) == 32 | ||
| ; run: %ctz_i128(0xF0000000_00000000, 0xFF000000_00000000) == 60 | ||
| ; run: %ctz_i128(0x00000001_00000000, 0x00000000_00000000) == 32 | ||
| ; run: %ctz_i128(0x00000000_00000000, 0x00000001_00000000) == 96 | ||
| ; run: %ctz_i128(0x00000000_00010000, 0x00000001_00000000) == 16 | ||
| ; run: %ctz_i128(0x00000000_00010000, 0x00000000_00000000) == 16 | ||
|
|
||
| function %clz_i128(i64, i64) -> i64 { | ||
| block0(v0: i64, v1: i64): | ||
| v2 = iconcat v0, v1 | ||
|
|
||
| v3 = clz v2 | ||
|
|
||
| v4, v5 = isplit v3 | ||
| v6 = iadd v4, v5 | ||
| return v6 | ||
| ; run: %ctz_i128(0x00000000_00000000_00000000_00000000) == 128 | ||
| ; run: %ctz_i128(0x00000000_00000000_FFFFFFFF_FFFFFFFF) == 0 | ||
| ; run: %ctz_i128(0xFFFFFFFF_FFFFFFFF_00000000_00000000) == 64 | ||
| ; run: %ctz_i128(0xFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF) == 0 | ||
| ; run: %ctz_i128(0xF0000000_00000000_FFFFFFFF_00000000) == 32 | ||
| ; run: %ctz_i128(0xFF000000_00000000_F0000000_00000000) == 60 | ||
| ; run: %ctz_i128(0x00000000_00000000_00000001_00000000) == 32 | ||
| ; run: %ctz_i128(0x00000001_00000000_00000000_00000000) == 96 | ||
| ; run: %ctz_i128(0x00000001_00000000_00000000_00010000) == 16 | ||
| ; run: %ctz_i128(0x00000000_00000000_00000000_00010000) == 16 | ||
|
|
||
| function %clz_i128(i128) -> i128 { | ||
| block0(v0: i128): | ||
| v1 = clz v0 | ||
| return v1 | ||
| } | ||
| ; run: %clz_i128(0x00000000_00000000, 0x00000000_00000000) == 128 | ||
| ; run: %clz_i128(0xFFFFFFFF_FFFFFFFF, 0x00000000_00000000) == 64 | ||
| ; run: %clz_i128(0x00000000_00000000, 0xFFFFFFFF_FFFFFFFF) == 0 | ||
| ; run: %clz_i128(0xFFFFFFFF_FFFFFFFF, 0xFFFFFFFF_FFFFFFFF) == 0 | ||
| ; run: %clz_i128(0xFFFFFFFF_FFFFFFFF, 0x40000000_00000000) == 1 | ||
| ; run: %clz_i128(0xFFFFFFFF_FFFFFFFF, 0x20000000_00000000) == 2 | ||
| ; run: %clz_i128(0x00000000_00000000, 0x00000000_80000000) == 32 | ||
| ; run: %clz_i128(0x00000000_00000000, 0x00000001_00000000) == 31 | ||
| ; run: %clz_i128(0x00000000_00010000, 0x00000001_00000000) == 31 | ||
| ; run: %clz_i128(0x00000000_00010000, 0x00000000_00000000) == 111 | ||
|
|
||
| function %popcnt_i128(i64, i64) -> i64 { | ||
| block0(v0: i64, v1: i64): | ||
| v2 = iconcat v0, v1 | ||
|
|
||
| v3 = popcnt v2 | ||
|
|
||
| v4, v5 = isplit v3 | ||
| v6 = iadd v4, v5 | ||
| return v6 | ||
| ; run: %clz_i128(0x00000000_00000000_00000000_00000000) == 128 | ||
| ; run: %clz_i128(0x00000000_00000000_FFFFFFFF_FFFFFFFF) == 64 | ||
| ; run: %clz_i128(0xFFFFFFFF_FFFFFFFF_00000000_00000000) == 0 | ||
| ; run: %clz_i128(0xFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF) == 0 | ||
| ; run: %clz_i128(0x40000000_00000000_FFFFFFFF_FFFFFFFF) == 1 | ||
| ; run: %clz_i128(0x20000000_00000000_FFFFFFFF_FFFFFFFF) == 2 | ||
| ; run: %clz_i128(0x00000000_80000000_00000000_00000000) == 32 | ||
| ; run: %clz_i128(0x00000001_00000000_00000000_00000000) == 31 | ||
| ; run: %clz_i128(0x00000001_00000000_00000000_00010000) == 31 | ||
| ; run: %clz_i128(0x00000000_00000000_00000000_00010000) == 111 | ||
|
|
||
| function %popcnt_i128(i128) -> i128 { | ||
| block0(v0: i128): | ||
| v1 = popcnt v0 | ||
| return v1 | ||
| } | ||
| ; run: %popcnt_i128(0x00000000_00000000, 0x00000000_00000000) == 0 | ||
| ; run: %popcnt_i128(0xFFFFFFFF_FFFFFFFF, 0x00000000_00000000) == 64 | ||
| ; run: %popcnt_i128(0x00000000_00000000, 0xFFFFFFFF_FFFFFFFF) == 64 | ||
| ; run: %popcnt_i128(0xFFFFFFFF_FFFFFFFF, 0xFFFFFFFF_FFFFFFFF) == 128 | ||
| ; run: %popcnt_i128(0x55555555_55555555, 0x55555555_55555555) == 64 | ||
| ; run: %popcnt_i128(0xC0FFEEEE_DECAFFFF, 0xDECAFFFF_C0FFEEEE) == 96 | ||
| ; run: %popcnt_i128(0x00000000_00000000_00000000_00000000) == 0 | ||
| ; run: %popcnt_i128(0x00000000_00000000_FFFFFFFF_FFFFFFFF) == 64 | ||
| ; run: %popcnt_i128(0xFFFFFFFF_FFFFFFFF_00000000_00000000) == 64 | ||
| ; run: %popcnt_i128(0xFFFFFFFF_FFFFFFFF_FFFFFFFF_FFFFFFFF) == 128 | ||
| ; run: %popcnt_i128(0x55555555_55555555_55555555_55555555) == 64 | ||
| ; run: %popcnt_i128(0xDECAFFFF_C0FFEEEE_C0FFEEEE_DECAFFFF) == 96 |
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.