about summary refs log tree commit diff
path: root/tests/mir-opt/building/custom/operators.rs
blob: 07abf2d965172935035bfa1bca8e6b54a077f7a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// skip-filecheck
//@ compile-flags: --crate-type=lib
#![feature(custom_mir, core_intrinsics)]
use std::intrinsics::mir::*;

// EMIT_MIR operators.f.built.after.mir
#[custom_mir(dialect = "built")]
pub fn f(a: i32, b: bool) -> i32 {
    mir! {
        {
            a = -a;
            b = !b;
            a = a + a;
            a = a - a;
            a = a * a;
            a = a / a;
            a = a % a;
            a = a ^ a;
            a = a & a;
            a = a << a;
            a = a >> a;
            b = a == a;
            b = a < a;
            b = a <= a;
            b = a >= a;
            b = a > a;
            let res = Checked(a + a);
            b = res.1;
            a = res.0;
            RET = a;
            Return()
        }
    }
}

// EMIT_MIR operators.g.runtime.after.mir
#[custom_mir(dialect = "runtime")]
pub fn g(p: *const i32, q: *const [i32]) {
    mir! {
        {
            let a = PtrMetadata(p);
            let b = PtrMetadata(q);
            Return()
        }
    }
}