Skip to content

Commit

Permalink
sample fn
Browse files Browse the repository at this point in the history
  • Loading branch information
jubitaneja committed Sep 20, 2018
1 parent 18ab2f4 commit 65b1e3e
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions fn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,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);
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
},
_ => {}
}
}

0 comments on commit 65b1e3e

Please sign in to comment.