-
Notifications
You must be signed in to change notification settings - Fork 7
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
feat(hugr-llvm): Emit ipow #1839
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ef6ab9e
feat: Emit `ipow` op
croyzor 1d08c4d
Add ipow tests with negative bases
croyzor 794a565
Add a comment about ipow exponent
croyzor b7769c6
Merge remote-tracking branch 'origin/main' into feat/more-int-ops
croyzor 3e9f7ca
cargo fmt
croyzor 9e64a04
Merge branch 'main' into emit-ipow
ss2165 d9e9bdc
Update extension specs
croyzor 90cbb49
Merge remote-tracking branch 'origin/main' into feat/more-int-ops
croyzor 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 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,41 @@ | ||
--- | ||
source: hugr-llvm/src/extension/int.rs | ||
expression: mod_str | ||
--- | ||
; ModuleID = 'test_context' | ||
source_filename = "test_context" | ||
|
||
define i8 @_hl.main.1(i8 %0, i8 %1) { | ||
alloca_block: | ||
br label %entry_block | ||
|
||
entry_block: ; preds = %alloca_block | ||
%acc_ptr = alloca i8, align 1 | ||
%exp_ptr = alloca i8, align 1 | ||
store i8 %0, i8* %acc_ptr, align 1 | ||
store i8 %1, i8* %exp_ptr, align 1 | ||
br label %pow | ||
|
||
pow: ; preds = %pow_body, %entry_block | ||
%acc = load i8, i8* %acc_ptr, align 1 | ||
%exp = load i8, i8* %exp_ptr, align 1 | ||
switch i8 %exp, label %pow_body [ | ||
i8 1, label %done | ||
i8 0, label %power_of_zero | ||
] | ||
|
||
power_of_zero: ; preds = %pow | ||
store i8 1, i8* %acc_ptr, align 1 | ||
br label %done | ||
|
||
pow_body: ; preds = %pow | ||
%new_acc = mul i8 %acc, %0 | ||
%new_exp = sub i8 %exp, 1 | ||
store i8 %new_acc, i8* %acc_ptr, align 1 | ||
store i8 %new_exp, i8* %exp_ptr, align 1 | ||
br label %pow | ||
|
||
done: ; preds = %pow, %power_of_zero | ||
%result = load i8, i8* %acc_ptr, align 1 | ||
ret i8 %result | ||
} |
53 changes: 53 additions & 0 deletions
53
...lvm/src/extension/snapshots/hugr_llvm__extension__int__test__ipow@[email protected]
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,53 @@ | ||
--- | ||
source: hugr-llvm/src/extension/int.rs | ||
expression: mod_str | ||
--- | ||
; ModuleID = 'test_context' | ||
source_filename = "test_context" | ||
|
||
define i8 @_hl.main.1(i8 %0, i8 %1) { | ||
alloca_block: | ||
%"0" = alloca i8, align 1 | ||
%"2_0" = alloca i8, align 1 | ||
%"2_1" = alloca i8, align 1 | ||
%"4_0" = alloca i8, align 1 | ||
br label %entry_block | ||
|
||
entry_block: ; preds = %alloca_block | ||
store i8 %0, i8* %"2_0", align 1 | ||
store i8 %1, i8* %"2_1", align 1 | ||
%"2_01" = load i8, i8* %"2_0", align 1 | ||
%"2_12" = load i8, i8* %"2_1", align 1 | ||
%acc_ptr = alloca i8, align 1 | ||
%exp_ptr = alloca i8, align 1 | ||
store i8 %"2_01", i8* %acc_ptr, align 1 | ||
store i8 %"2_12", i8* %exp_ptr, align 1 | ||
br label %pow | ||
|
||
pow: ; preds = %pow_body, %entry_block | ||
%acc = load i8, i8* %acc_ptr, align 1 | ||
%exp = load i8, i8* %exp_ptr, align 1 | ||
switch i8 %exp, label %pow_body [ | ||
i8 1, label %done | ||
i8 0, label %power_of_zero | ||
] | ||
|
||
power_of_zero: ; preds = %pow | ||
store i8 1, i8* %acc_ptr, align 1 | ||
br label %done | ||
|
||
pow_body: ; preds = %pow | ||
%new_acc = mul i8 %acc, %"2_01" | ||
%new_exp = sub i8 %exp, 1 | ||
store i8 %new_acc, i8* %acc_ptr, align 1 | ||
store i8 %new_exp, i8* %exp_ptr, align 1 | ||
br label %pow | ||
|
||
done: ; preds = %pow, %power_of_zero | ||
%result = load i8, i8* %acc_ptr, align 1 | ||
store i8 %result, i8* %"4_0", align 1 | ||
%"4_03" = load i8, i8* %"4_0", align 1 | ||
store i8 %"4_03", i8* %"0", align 1 | ||
%"04" = load i8, i8* %"0", align 1 | ||
ret i8 %"04" | ||
} |
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.
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.
Could you also add some similar tests to
test_exec_signed_bin_op
for negative bases?