|
| 1 | +// Verify that our intrinsics generate the correct LLVM calls for f128 |
| 2 | + |
| 3 | +#![crate_type = "lib"] |
| 4 | +#![feature(f128)] |
| 5 | +#![feature(core_intrinsics)] |
| 6 | + |
| 7 | +// CHECK-LABEL: i1 @f128_eq( |
| 8 | +#[no_mangle] |
| 9 | +pub fn f128_eq(a: f128, b: f128) -> bool { |
| 10 | + // CHECK: fcmp oeq fp128 %{{.+}}, %{{.+}} |
| 11 | + a == b |
| 12 | +} |
| 13 | + |
| 14 | +// CHECK-LABEL: i1 @f128_ne( |
| 15 | +#[no_mangle] |
| 16 | +pub fn f128_ne(a: f128, b: f128) -> bool { |
| 17 | + // CHECK: fcmp une fp128 %{{.+}}, %{{.+}} |
| 18 | + a != b |
| 19 | +} |
| 20 | + |
| 21 | +// CHECK-LABEL: i1 @f128_gt( |
| 22 | +#[no_mangle] |
| 23 | +pub fn f128_gt(a: f128, b: f128) -> bool { |
| 24 | + // CHECK: fcmp ogt fp128 %{{.+}}, %{{.+}} |
| 25 | + a > b |
| 26 | +} |
| 27 | + |
| 28 | +// CHECK-LABEL: i1 @f128_ge( |
| 29 | +#[no_mangle] |
| 30 | +pub fn f128_ge(a: f128, b: f128) -> bool { |
| 31 | + // CHECK: fcmp oge fp128 %{{.+}}, %{{.+}} |
| 32 | + a >= b |
| 33 | +} |
| 34 | + |
| 35 | +// CHECK-LABEL: i1 @f128_lt( |
| 36 | +#[no_mangle] |
| 37 | +pub fn f128_lt(a: f128, b: f128) -> bool { |
| 38 | + // CHECK: fcmp olt fp128 %{{.+}}, %{{.+}} |
| 39 | + a < b |
| 40 | +} |
| 41 | + |
| 42 | +// CHECK-LABEL: i1 @f128_le( |
| 43 | +#[no_mangle] |
| 44 | +pub fn f128_le(a: f128, b: f128) -> bool { |
| 45 | + // CHECK: fcmp ole fp128 %{{.+}}, %{{.+}} |
| 46 | + a <= b |
| 47 | +} |
| 48 | + |
| 49 | +// CHECK-LABEL: fp128 @f128_neg( |
| 50 | +#[no_mangle] |
| 51 | +pub fn f128_neg(a: f128) -> f128 { |
| 52 | + // CHECK: fneg fp128 |
| 53 | + -a |
| 54 | +} |
| 55 | + |
| 56 | +// CHECK-LABEL: fp128 @f128_add( |
| 57 | +#[no_mangle] |
| 58 | +pub fn f128_add(a: f128, b: f128) -> f128 { |
| 59 | + // CHECK: fadd fp128 %{{.+}}, %{{.+}} |
| 60 | + a + b |
| 61 | +} |
| 62 | + |
| 63 | +// CHECK-LABEL: fp128 @f128_sub( |
| 64 | +#[no_mangle] |
| 65 | +pub fn f128_sub(a: f128, b: f128) -> f128 { |
| 66 | + // CHECK: fsub fp128 %{{.+}}, %{{.+}} |
| 67 | + a - b |
| 68 | +} |
| 69 | + |
| 70 | +// CHECK-LABEL: fp128 @f128_mul( |
| 71 | +#[no_mangle] |
| 72 | +pub fn f128_mul(a: f128, b: f128) -> f128 { |
| 73 | + // CHECK: fmul fp128 %{{.+}}, %{{.+}} |
| 74 | + a * b |
| 75 | +} |
| 76 | + |
| 77 | +// CHECK-LABEL: fp128 @f128_div( |
| 78 | +#[no_mangle] |
| 79 | +pub fn f128_div(a: f128, b: f128) -> f128 { |
| 80 | + // CHECK: fdiv fp128 %{{.+}}, %{{.+}} |
| 81 | + a / b |
| 82 | +} |
| 83 | + |
| 84 | +// CHECK-LABEL: fp128 @f128_rem( |
| 85 | +#[no_mangle] |
| 86 | +pub fn f128_rem(a: f128, b: f128) -> f128 { |
| 87 | + // CHECK: frem fp128 %{{.+}}, %{{.+}} |
| 88 | + a % b |
| 89 | +} |
| 90 | + |
| 91 | +// CHECK-LABEL: void @f128_add_assign( |
| 92 | +#[no_mangle] |
| 93 | +pub fn f128_add_assign(a: &mut f128, b: f128) { |
| 94 | + // CHECK: fadd fp128 %{{.+}}, %{{.+}} |
| 95 | + // CHECK-NEXT: store fp128 %{{.+}}, ptr %{{.+}} |
| 96 | + *a += b; |
| 97 | +} |
| 98 | + |
| 99 | +// CHECK-LABEL: void @f128_sub_assign( |
| 100 | +#[no_mangle] |
| 101 | +pub fn f128_sub_assign(a: &mut f128, b: f128) { |
| 102 | + // CHECK: fsub fp128 %{{.+}}, %{{.+}} |
| 103 | + // CHECK-NEXT: store fp128 %{{.+}}, ptr %{{.+}} |
| 104 | + *a -= b; |
| 105 | +} |
| 106 | + |
| 107 | +// CHECK-LABEL: void @f128_mul_assign( |
| 108 | +#[no_mangle] |
| 109 | +pub fn f128_mul_assign(a: &mut f128, b: f128) { |
| 110 | + // CHECK: fmul fp128 %{{.+}}, %{{.+}} |
| 111 | + // CHECK-NEXT: store fp128 %{{.+}}, ptr %{{.+}} |
| 112 | + *a *= b |
| 113 | +} |
| 114 | + |
| 115 | +// CHECK-LABEL: void @f128_div_assign( |
| 116 | +#[no_mangle] |
| 117 | +pub fn f128_div_assign(a: &mut f128, b: f128) { |
| 118 | + // CHECK: fdiv fp128 %{{.+}}, %{{.+}} |
| 119 | + // CHECK-NEXT: store fp128 %{{.+}}, ptr %{{.+}} |
| 120 | + *a /= b |
| 121 | +} |
| 122 | + |
| 123 | +// CHECK-LABEL: void @f128_rem_assign( |
| 124 | +#[no_mangle] |
| 125 | +pub fn f128_rem_assign(a: &mut f128, b: f128) { |
| 126 | + // CHECK: frem fp128 %{{.+}}, %{{.+}} |
| 127 | + // CHECK-NEXT: store fp128 %{{.+}}, ptr %{{.+}} |
| 128 | + *a %= b |
| 129 | +} |
0 commit comments