-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
162 additions
and
2 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
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" | ||
} |