|
| 1 | +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +#![crate_type = "lib"] |
| 12 | +#![feature(core_intrinsics)] |
| 13 | + |
| 14 | +use std::intrinsics::*; |
| 15 | + |
| 16 | +// CHECK-LABEL: @nowrap_add_signed |
| 17 | +#[no_mangle] |
| 18 | +pub unsafe fn nowrap_add_signed(a: i32, b: i32) -> i32 { |
| 19 | + // CHECK: add nsw |
| 20 | + nowrap_add(a, b) |
| 21 | +} |
| 22 | + |
| 23 | +// CHECK-LABEL: @nowrap_add_unsigned |
| 24 | +#[no_mangle] |
| 25 | +pub unsafe fn nowrap_add_unsigned(a: u32, b: u32) -> u32 { |
| 26 | + // CHECK: add nuw |
| 27 | + nowrap_add(a, b) |
| 28 | +} |
| 29 | + |
| 30 | +// CHECK-LABEL: @nowrap_sub_signed |
| 31 | +#[no_mangle] |
| 32 | +pub unsafe fn nowrap_sub_signed(a: i32, b: i32) -> i32 { |
| 33 | + // CHECK: sub nsw |
| 34 | + nowrap_sub(a, b) |
| 35 | +} |
| 36 | + |
| 37 | +// CHECK-LABEL: @nowrap_sub_unsigned |
| 38 | +#[no_mangle] |
| 39 | +pub unsafe fn nowrap_sub_unsigned(a: u32, b: u32) -> u32 { |
| 40 | + // CHECK: sub nuw |
| 41 | + nowrap_sub(a, b) |
| 42 | +} |
| 43 | + |
| 44 | +// CHECK-LABEL: @nowrap_mul_signed |
| 45 | +#[no_mangle] |
| 46 | +pub unsafe fn nowrap_mul_signed(a: i32, b: i32) -> i32 { |
| 47 | + // CHECK: mul nsw |
| 48 | + nowrap_mul(a, b) |
| 49 | +} |
| 50 | + |
| 51 | +// CHECK-LABEL: @nowrap_mul_unsigned |
| 52 | +#[no_mangle] |
| 53 | +pub unsafe fn nowrap_mul_unsigned(a: u32, b: u32) -> u32 { |
| 54 | + // CHECK: mul nuw |
| 55 | + nowrap_mul(a, b) |
| 56 | +} |
| 57 | + |
| 58 | +// CHECK-LABEL: @nowrap_neg_signed |
| 59 | +#[no_mangle] |
| 60 | +pub unsafe fn nowrap_neg_signed(a: i32) -> i32 { |
| 61 | + // CHECK: sub nsw i32 0, |
| 62 | + nowrap_neg(a) |
| 63 | +} |
| 64 | + |
| 65 | +// CHECK-LABEL: @nowrap_neg_unsigned |
| 66 | +#[no_mangle] |
| 67 | +pub unsafe fn nowrap_neg_unsigned(a: u32) -> u32 { |
| 68 | + // CHECK: ret i32 0 |
| 69 | + nowrap_neg(a) |
| 70 | +} |
0 commit comments