-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfn.rs
45 lines (45 loc) · 2.23 KB
/
fn.rs
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
fn peep_opt (pos: &mut FuncCursor, inst: Inst) {
match pos.func.dfg[inst] {
InstructionData::Binary { opcode, args } => {
match opcode {
Opcode::Iadd => {
match pos.func.dfg.value_def(args[0]) {
ValueDef::Param(_, _) => {
match pos.func.dfg.value_def(args[1]) {
ValueDef::Result(arg_ty, _) => {
match pos.func.dfg[arg_ty] {
InstructionData::Binary {opcode, args} => {
match opcode {
Opcode::Iadd => {
match pos.func.dfg.value_def(args[0]) {
ValueDef::Param(_, _) => {
match pos.func.dfg.value_def(args[1]) {
ValueDef::Param(_, _) => {
pos.func.dfg
.replace(inst)
.imul_imm(args[1], 3);
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
}