To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

ir_semantics.rs 2.5 KB
Newer Older
qinsoon's avatar
qinsoon committed
1
2
use inst::*;
use inst::Instruction_::*;
3
4
5
6
7

pub fn is_terminal_inst(inst: &Instruction_) -> bool {
    match inst {
        &BinOp(_, _, _) 
        | &CmpOp(_, _, _)
qinsoon's avatar
qinsoon committed
8
        | &ConvOp{..}
9
        | &ExprCall{..}
qinsoon's avatar
qinsoon committed
10
        | &ExprCCall{..}
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
        | &Load{..}
        | &Store{..}
        | &CmpXchg{..}
        | &AtomicRMW{..}
        | &New(_)
        | &AllocA(_)
        | &NewHybrid(_, _)
        | &AllocAHybrid(_, _)
        | &NewStack(_)
        | &NewThread(_, _)
        | &NewThreadExn(_, _)
        | &NewFrameCursor(_)
        | &GetIRef(_)
        | &GetFieldIRef{..}
        | &GetElementIRef{..}
        | &ShiftIRef{..}
        | &GetVarPartIRef{..}
qinsoon's avatar
qinsoon committed
28
        | &Select{..}
29
30
31
        | &Fence(_)
        | &CommonInst_GetThreadLocal
        | &CommonInst_SetThreadLocal(_) => false,
32
33
34
35
36
37
38
39
40
        &Return(_)
        | &ThreadExit
        | &Throw(_)
        | &TailCall(_)
        | &Branch1(_)
        | &Branch2{..}
        | &Watchpoint{..}
        | &WPBranch{..}
        | &Call{..}
qinsoon's avatar
qinsoon committed
41
        | &CCall{..}
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
        | &SwapStack{..}
        | &Switch{..}
        | &ExnInstruction{..} => true
    }
}

pub fn is_non_terminal_inst(inst: &Instruction_) -> bool {
    !is_terminal_inst(inst)
}

// FIXME: check the correctness
pub fn has_side_effect(inst: &Instruction_) -> bool {
    match inst {
        &BinOp(_, _, _) => false,
        &CmpOp(_, _, _) => false,
qinsoon's avatar
qinsoon committed
57
        &ConvOp{..} => false,
58
        &ExprCall{..} => true,
qinsoon's avatar
qinsoon committed
59
        &ExprCCall{..} => true,
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
        &Load{..} => true,
        &Store{..} => true,
        &CmpXchg{..} => true,
        &AtomicRMW{..} => true,
        &New(_) => true,
        &AllocA(_) => true,
        &NewHybrid(_, _) => true,
        &AllocAHybrid(_, _) => true,
        &NewStack(_) => true,
        &NewThread(_, _) => true,
        &NewThreadExn(_, _) => true,
        &NewFrameCursor(_) => true,
        &GetIRef(_) => false,
        &GetFieldIRef{..} => false,
        &GetElementIRef{..} => false,
        &ShiftIRef{..} => false,
        &GetVarPartIRef{..} => false,
        &Fence(_) => true,
        &Return(_) => true,
        &ThreadExit => true,
        &Throw(_) => true,
        &TailCall(_) => true,
        &Branch1(_) => true,
        &Branch2{..} => true,
qinsoon's avatar
qinsoon committed
84
        &Select{..} => false,
85
86
87
        &Watchpoint{..} => true,
        &WPBranch{..} => true,
        &Call{..} => true,
qinsoon's avatar
qinsoon committed
88
        &CCall{..} => true,
89
90
        &SwapStack{..} => true,
        &Switch{..} => true,
91
92
93
        &ExnInstruction{..} => true,
        &CommonInst_GetThreadLocal => true,
        &CommonInst_SetThreadLocal(_) => true,
94
    }
95
}