Skip to content

Commit 7f7fd27

Browse files
committed
Add exhaustive codegen tests for stable API.
1 parent 6f3d910 commit 7f7fd27

File tree

4 files changed

+158
-0
lines changed

4 files changed

+158
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Verify that algebraic intrinsics generate the correct LLVM calls for f128
2+
3+
#![crate_type = "lib"]
4+
#![feature(f128)]
5+
#![feature(float_algebraic)]
6+
7+
// CHECK-LABEL: fp128 @f128_algebraic_add(
8+
#[no_mangle]
9+
pub fn f128_algebraic_add(a: f128, b: f128) -> f128 {
10+
// CHECK: fadd reassoc nsz arcp contract fp128 {{(%a, %b)|(%b, %a)}}
11+
a.algebraic_add(b)
12+
}
13+
14+
// CHECK-LABEL: fp128 @f128_algebraic_sub(
15+
#[no_mangle]
16+
pub fn f128_algebraic_sub(a: f128, b: f128) -> f128 {
17+
// CHECK: fsub reassoc nsz arcp contract fp128 %a, %b
18+
a.algebraic_sub(b)
19+
}
20+
21+
// CHECK-LABEL: fp128 @f128_algebraic_mul(
22+
#[no_mangle]
23+
pub fn f128_algebraic_mul(a: f128, b: f128) -> f128 {
24+
// CHECK: fmul reassoc nsz arcp contract fp128 {{(%a, %b)|(%b, %a)}}
25+
a.algebraic_mul(b)
26+
}
27+
28+
// CHECK-LABEL: fp128 @f128_algebraic_div(
29+
#[no_mangle]
30+
pub fn f128_algebraic_div(a: f128, b: f128) -> f128 {
31+
// CHECK: fdiv reassoc nsz arcp contract fp128 %a, %b
32+
a.algebraic_div(b)
33+
}
34+
35+
// CHECK-LABEL: fp128 @f128_algebraic_rem(
36+
#[no_mangle]
37+
pub fn f128_algebraic_rem(a: f128, b: f128) -> f128 {
38+
// CHECK: frem reassoc nsz arcp contract fp128 %a, %b
39+
a.algebraic_rem(b)
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Verify that algebraic intrinsics generate the correct LLVM calls for f16
2+
3+
#![crate_type = "lib"]
4+
#![feature(f16)]
5+
#![feature(float_algebraic)]
6+
7+
// CHECK-LABEL: half @f16_algebraic_add(
8+
#[no_mangle]
9+
pub fn f16_algebraic_add(a: f16, b: f16) -> f16 {
10+
// CHECK: fadd reassoc nsz arcp contract half {{(%a, %b)|(%b, %a)}}
11+
a.algebraic_add(b)
12+
}
13+
14+
// CHECK-LABEL: half @f16_algebraic_sub(
15+
#[no_mangle]
16+
pub fn f16_algebraic_sub(a: f16, b: f16) -> f16 {
17+
// CHECK: fsub reassoc nsz arcp contract half %a, %b
18+
a.algebraic_sub(b)
19+
}
20+
21+
// CHECK-LABEL: half @f16_algebraic_mul(
22+
#[no_mangle]
23+
pub fn f16_algebraic_mul(a: f16, b: f16) -> f16 {
24+
// CHECK: fmul reassoc nsz arcp contract half {{(%a, %b)|(%b, %a)}}
25+
a.algebraic_mul(b)
26+
}
27+
28+
// CHECK-LABEL: half @f16_algebraic_div(
29+
#[no_mangle]
30+
pub fn f16_algebraic_div(a: f16, b: f16) -> f16 {
31+
// CHECK: fdiv reassoc nsz arcp contract half %a, %b
32+
a.algebraic_div(b)
33+
}
34+
35+
// CHECK-LABEL: half @f16_algebraic_rem(
36+
#[no_mangle]
37+
pub fn f16_algebraic_rem(a: f16, b: f16) -> f16 {
38+
// CHECK: frem reassoc nsz arcp contract half %a, %b
39+
a.algebraic_rem(b)
40+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Verify that algebraic intrinsics generate the correct LLVM calls for f32
2+
3+
#![crate_type = "lib"]
4+
#![feature(float_algebraic)]
5+
6+
// CHECK-LABEL: float @f32_algebraic_add(
7+
#[no_mangle]
8+
pub fn f32_algebraic_add(a: f32, b: f32) -> f32 {
9+
// CHECK: fadd reassoc nsz arcp contract float {{(%a, %b)|(%b, %a)}}
10+
a.algebraic_add(b)
11+
}
12+
13+
// CHECK-LABEL: float @f32_algebraic_sub(
14+
#[no_mangle]
15+
pub fn f32_algebraic_sub(a: f32, b: f32) -> f32 {
16+
// CHECK: fsub reassoc nsz arcp contract float %a, %b
17+
a.algebraic_sub(b)
18+
}
19+
20+
// CHECK-LABEL: float @f32_algebraic_mul(
21+
#[no_mangle]
22+
pub fn f32_algebraic_mul(a: f32, b: f32) -> f32 {
23+
// CHECK: fmul reassoc nsz arcp contract float {{(%a, %b)|(%b, %a)}}
24+
a.algebraic_mul(b)
25+
}
26+
27+
// CHECK-LABEL: float @f32_algebraic_div(
28+
#[no_mangle]
29+
pub fn f32_algebraic_div(a: f32, b: f32) -> f32 {
30+
// CHECK: fdiv reassoc nsz arcp contract float %a, %b
31+
a.algebraic_div(b)
32+
}
33+
34+
// CHECK-LABEL: float @f32_algebraic_rem(
35+
#[no_mangle]
36+
pub fn f32_algebraic_rem(a: f32, b: f32) -> f32 {
37+
// CHECK: frem reassoc nsz arcp contract float %a, %b
38+
a.algebraic_rem(b)
39+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Verify that algebraic intrinsics generate the correct LLVM calls for f64
2+
3+
#![crate_type = "lib"]
4+
#![feature(float_algebraic)]
5+
6+
// CHECK-LABEL: double @f64_algebraic_add(
7+
#[no_mangle]
8+
pub fn f64_algebraic_add(a: f64, b: f64) -> f64 {
9+
// CHECK: fadd reassoc nsz arcp contract double {{(%a, %b)|(%b, %a)}}
10+
a.algebraic_add(b)
11+
}
12+
13+
// CHECK-LABEL: double @f64_algebraic_sub(
14+
#[no_mangle]
15+
pub fn f64_algebraic_sub(a: f64, b: f64) -> f64 {
16+
// CHECK: fsub reassoc nsz arcp contract double %a, %b
17+
a.algebraic_sub(b)
18+
}
19+
20+
// CHECK-LABEL: double @f64_algebraic_mul(
21+
#[no_mangle]
22+
pub fn f64_algebraic_mul(a: f64, b: f64) -> f64 {
23+
// CHECK: fmul reassoc nsz arcp contract double {{(%a, %b)|(%b, %a)}}
24+
a.algebraic_mul(b)
25+
}
26+
27+
// CHECK-LABEL: double @f64_algebraic_div(
28+
#[no_mangle]
29+
pub fn f64_algebraic_div(a: f64, b: f64) -> f64 {
30+
// CHECK: fdiv reassoc nsz arcp contract double %a, %b
31+
a.algebraic_div(b)
32+
}
33+
34+
// CHECK-LABEL: double @f64_algebraic_rem(
35+
#[no_mangle]
36+
pub fn f64_algebraic_rem(a: f64, b: f64) -> f64 {
37+
// CHECK: frem reassoc nsz arcp contract double %a, %b
38+
a.algebraic_rem(b)
39+
}

0 commit comments

Comments
 (0)