Skip to content

Commit

Permalink
Merge pull request #401 from 0xPolygonMiden/greenhat/i363-more-tests-…
Browse files Browse the repository at this point in the history
…hir2

tests: switch `instructions`, `intrinsics`, and `types` test suites to HIR2
  • Loading branch information
bitwalker authored Feb 14, 2025
2 parents 9555b0f + b7b2666 commit c873686
Show file tree
Hide file tree
Showing 125 changed files with 2,721 additions and 2,529 deletions.
32 changes: 14 additions & 18 deletions tests/integration/expected/add_felt.hir
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
(component
;; Modules
(module #add_felt
;; Constants
(const (id 0) 0x00100000)
builtin.component #[name = #root] #[namespace = #root_ns] #[version = 1.0.0] #[visibility = public] {

;; Global Variables
(global (export #__stack_pointer) (id 0) (type i32) (const 0))
builtin.module #[name = #add_felt] #[visibility = public] {

;; Functions
(func (export #entrypoint) (param felt) (param felt) (result felt)
(block 0 (param v0 felt) (param v1 felt)
(let (v3 felt) (add.unchecked v0 v1))
(br (block 1 v3)))
builtin.function public @entrypoint(v0: felt, v1: felt) -> felt {
^block3(v0: felt, v1: felt):
v3 = hir.add v0, v1 : felt #[overflow = unchecked];
hir.br block4 v3;
^block4(v2: felt):
hir.ret v2;
};
builtin.global_variable #[name = #__stack_pointer] #[ty = i32] #[visibility = private] {

(block 1 (param v2 felt)
(ret v2))
)
)

)
hir.ret_imm #[value = 1048576];
};
};
};
41 changes: 22 additions & 19 deletions tests/integration/expected/add_i16.hir
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
(component
;; Modules
(module #test_rust_4a80dace0dddc4f08e0a7761b4e1d269aa474b6beb14702baa097a4626d593c1
;; Constants
(const (id 0) 0x00100000)
builtin.component #[name = #root] #[namespace = #root_ns] #[version = 1.0.0] #[visibility = public] {

;; Global Variables
(global (export #__stack_pointer) (id 0) (type i32) (const 0))
(global (export #gv1) (id 1) (type i32) (const 0))
(global (export #gv2) (id 2) (type i32) (const 0))
builtin.module #[name = #test_rust_4a80dace0dddc4f08e0a7761b4e1d269aa474b6beb14702baa097a4626d593c1] #[visibility = public] {

;; Functions
(func (export #entrypoint) (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v3 i32) (add.wrapping v1 v0))
(br (block 1 v3)))
builtin.function public @entrypoint(v0: i32, v1: i32) -> i32 {
^block5(v0: i32, v1: i32):
v3 = hir.add v1, v0 : i32 #[overflow = wrapping];
v4 = hir.sext v3 : i32 #[ty = i32];
hir.br block6 v4;
^block6(v2: i32):
hir.ret v2;
};
builtin.global_variable #[name = #__stack_pointer] #[ty = i32] #[visibility = private] {

(block 1 (param v2 i32)
(ret v2))
)
)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv1] #[ty = i32] #[visibility = public] {

)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv2] #[ty = i32] #[visibility = public] {

hir.ret_imm #[value = 1048576];
};
};
};
40 changes: 21 additions & 19 deletions tests/integration/expected/add_i32.hir
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
(component
;; Modules
(module #test_rust_cc3b19fe60136e21eb08ffee1b6d6f2a6534ca0afa46f10f5296cdb8f0adfc30
;; Constants
(const (id 0) 0x00100000)
builtin.component #[name = #root] #[namespace = #root_ns] #[version = 1.0.0] #[visibility = public] {

;; Global Variables
(global (export #__stack_pointer) (id 0) (type i32) (const 0))
(global (export #gv1) (id 1) (type i32) (const 0))
(global (export #gv2) (id 2) (type i32) (const 0))
builtin.module #[name = #test_rust_cc3b19fe60136e21eb08ffee1b6d6f2a6534ca0afa46f10f5296cdb8f0adfc30] #[visibility = public] {

;; Functions
(func (export #entrypoint) (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v3 i32) (add.wrapping v1 v0))
(br (block 1 v3)))
builtin.function public @entrypoint(v0: i32, v1: i32) -> i32 {
^block5(v0: i32, v1: i32):
v3 = hir.add v1, v0 : i32 #[overflow = wrapping];
hir.br block6 v3;
^block6(v2: i32):
hir.ret v2;
};
builtin.global_variable #[name = #__stack_pointer] #[ty = i32] #[visibility = private] {

(block 1 (param v2 i32)
(ret v2))
)
)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv1] #[ty = i32] #[visibility = public] {

)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv2] #[ty = i32] #[visibility = public] {

hir.ret_imm #[value = 1048576];
};
};
};
40 changes: 21 additions & 19 deletions tests/integration/expected/add_i64.hir
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
(component
;; Modules
(module #test_rust_069cf45252371f826e737bc3d7f808e1df77c97acac642efbaf976f4ab507131
;; Constants
(const (id 0) 0x00100000)
builtin.component #[name = #root] #[namespace = #root_ns] #[version = 1.0.0] #[visibility = public] {

;; Global Variables
(global (export #__stack_pointer) (id 0) (type i32) (const 0))
(global (export #gv1) (id 1) (type i32) (const 0))
(global (export #gv2) (id 2) (type i32) (const 0))
builtin.module #[name = #test_rust_069cf45252371f826e737bc3d7f808e1df77c97acac642efbaf976f4ab507131] #[visibility = public] {

;; Functions
(func (export #entrypoint) (param i64) (param i64) (result i64)
(block 0 (param v0 i64) (param v1 i64)
(let (v3 i64) (add.wrapping v1 v0))
(br (block 1 v3)))
builtin.function public @entrypoint(v0: i64, v1: i64) -> i64 {
^block5(v0: i64, v1: i64):
v3 = hir.add v1, v0 : i64 #[overflow = wrapping];
hir.br block6 v3;
^block6(v2: i64):
hir.ret v2;
};
builtin.global_variable #[name = #__stack_pointer] #[ty = i32] #[visibility = private] {

(block 1 (param v2 i64)
(ret v2))
)
)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv1] #[ty = i32] #[visibility = public] {

)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv2] #[ty = i32] #[visibility = public] {

hir.ret_imm #[value = 1048576];
};
};
};
41 changes: 22 additions & 19 deletions tests/integration/expected/add_i8.hir
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
(component
;; Modules
(module #test_rust_3dc5f4de1f29681a88ff9608b56c29738ebfd35b5bf875f151de489b1c7e50f7
;; Constants
(const (id 0) 0x00100000)
builtin.component #[name = #root] #[namespace = #root_ns] #[version = 1.0.0] #[visibility = public] {

;; Global Variables
(global (export #__stack_pointer) (id 0) (type i32) (const 0))
(global (export #gv1) (id 1) (type i32) (const 0))
(global (export #gv2) (id 2) (type i32) (const 0))
builtin.module #[name = #test_rust_3dc5f4de1f29681a88ff9608b56c29738ebfd35b5bf875f151de489b1c7e50f7] #[visibility = public] {

;; Functions
(func (export #entrypoint) (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v3 i32) (add.wrapping v1 v0))
(br (block 1 v3)))
builtin.function public @entrypoint(v0: i32, v1: i32) -> i32 {
^block5(v0: i32, v1: i32):
v3 = hir.add v1, v0 : i32 #[overflow = wrapping];
v4 = hir.sext v3 : i32 #[ty = i32];
hir.br block6 v4;
^block6(v2: i32):
hir.ret v2;
};
builtin.global_variable #[name = #__stack_pointer] #[ty = i32] #[visibility = private] {

(block 1 (param v2 i32)
(ret v2))
)
)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv1] #[ty = i32] #[visibility = public] {

)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv2] #[ty = i32] #[visibility = public] {

hir.ret_imm #[value = 1048576];
};
};
};
44 changes: 23 additions & 21 deletions tests/integration/expected/add_u16.hir
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
(component
;; Modules
(module #test_rust_711c7705576a28225a7e87d297c54811b91eb1b69f3f407376a0af96dcad37b2
;; Constants
(const (id 0) 0x00100000)
builtin.component #[name = #root] #[namespace = #root_ns] #[version = 1.0.0] #[visibility = public] {

;; Global Variables
(global (export #__stack_pointer) (id 0) (type i32) (const 0))
(global (export #gv1) (id 1) (type i32) (const 0))
(global (export #gv2) (id 2) (type i32) (const 0))
builtin.module #[name = #test_rust_711c7705576a28225a7e87d297c54811b91eb1b69f3f407376a0af96dcad37b2] #[visibility = public] {

;; Functions
(func (export #entrypoint) (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v3 i32) (add.wrapping v1 v0))
(let (v4 i32) (const.i32 65535))
(let (v5 i32) (band v3 v4))
(br (block 1 v5)))
builtin.function public @entrypoint(v0: i32, v1: i32) -> i32 {
^block5(v0: i32, v1: i32):
v3 = hir.add v1, v0 : i32 #[overflow = wrapping];
v4 = hir.constant 65535 : i32;
v5 = hir.band v3, v4 : i32;
hir.br block6 v5;
^block6(v2: i32):
hir.ret v2;
};
builtin.global_variable #[name = #__stack_pointer] #[ty = i32] #[visibility = private] {

(block 1 (param v2 i32)
(ret v2))
)
)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv1] #[ty = i32] #[visibility = public] {

)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv2] #[ty = i32] #[visibility = public] {

hir.ret_imm #[value = 1048576];
};
};
};
40 changes: 21 additions & 19 deletions tests/integration/expected/add_u32.hir
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
(component
;; Modules
(module #test_rust_ca3478b0c28e59b401b0d632fb0a1c51d0c45a319d503d2a2a705107e8aab84f
;; Constants
(const (id 0) 0x00100000)
builtin.component #[name = #root] #[namespace = #root_ns] #[version = 1.0.0] #[visibility = public] {

;; Global Variables
(global (export #__stack_pointer) (id 0) (type i32) (const 0))
(global (export #gv1) (id 1) (type i32) (const 0))
(global (export #gv2) (id 2) (type i32) (const 0))
builtin.module #[name = #test_rust_ca3478b0c28e59b401b0d632fb0a1c51d0c45a319d503d2a2a705107e8aab84f] #[visibility = public] {

;; Functions
(func (export #entrypoint) (param i32) (param i32) (result i32)
(block 0 (param v0 i32) (param v1 i32)
(let (v3 i32) (add.wrapping v1 v0))
(br (block 1 v3)))
builtin.function public @entrypoint(v0: i32, v1: i32) -> i32 {
^block5(v0: i32, v1: i32):
v3 = hir.add v1, v0 : i32 #[overflow = wrapping];
hir.br block6 v3;
^block6(v2: i32):
hir.ret v2;
};
builtin.global_variable #[name = #__stack_pointer] #[ty = i32] #[visibility = private] {

(block 1 (param v2 i32)
(ret v2))
)
)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv1] #[ty = i32] #[visibility = public] {

)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv2] #[ty = i32] #[visibility = public] {

hir.ret_imm #[value = 1048576];
};
};
};
40 changes: 21 additions & 19 deletions tests/integration/expected/add_u64.hir
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
(component
;; Modules
(module #test_rust_11c5a2e5412edeeffd507e0b820658a62ad960143f3b5167b2fe215d1ecfecfa
;; Constants
(const (id 0) 0x00100000)
builtin.component #[name = #root] #[namespace = #root_ns] #[version = 1.0.0] #[visibility = public] {

;; Global Variables
(global (export #__stack_pointer) (id 0) (type i32) (const 0))
(global (export #gv1) (id 1) (type i32) (const 0))
(global (export #gv2) (id 2) (type i32) (const 0))
builtin.module #[name = #test_rust_11c5a2e5412edeeffd507e0b820658a62ad960143f3b5167b2fe215d1ecfecfa] #[visibility = public] {

;; Functions
(func (export #entrypoint) (param i64) (param i64) (result i64)
(block 0 (param v0 i64) (param v1 i64)
(let (v3 i64) (add.wrapping v1 v0))
(br (block 1 v3)))
builtin.function public @entrypoint(v0: i64, v1: i64) -> i64 {
^block5(v0: i64, v1: i64):
v3 = hir.add v1, v0 : i64 #[overflow = wrapping];
hir.br block6 v3;
^block6(v2: i64):
hir.ret v2;
};
builtin.global_variable #[name = #__stack_pointer] #[ty = i32] #[visibility = private] {

(block 1 (param v2 i64)
(ret v2))
)
)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv1] #[ty = i32] #[visibility = public] {

)
hir.ret_imm #[value = 1048576];
};
builtin.global_variable #[name = #gv2] #[ty = i32] #[visibility = public] {

hir.ret_imm #[value = 1048576];
};
};
};
Loading

0 comments on commit c873686

Please sign in to comment.