mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-14 22:38:46 +00:00
HW3 (3)
This commit is contained in:
@@ -136,6 +136,8 @@ impl Optimize<FunctionDefinition> for SimplifyCfgMerge {
|
||||
}
|
||||
}
|
||||
|
||||
code.blocks.retain(|bid, _| !merged_to.contains_key(bid));
|
||||
|
||||
for (bid, block) in &mut code.blocks {
|
||||
for inst in block.instructions.iter_mut() {
|
||||
replace_instruction_operands(inst, &replaces);
|
||||
@@ -143,7 +145,6 @@ impl Optimize<FunctionDefinition> for SimplifyCfgMerge {
|
||||
replace_exit_operands(&mut block.exit, &replaces);
|
||||
}
|
||||
|
||||
code.blocks.retain(|bid, _| !merged_to.contains_key(bid));
|
||||
!merged_to.is_empty()
|
||||
}
|
||||
}
|
||||
@@ -290,25 +291,19 @@ fn replace_instruction_operands(inst: &mut Instruction, replaces: &HashMap<Regis
|
||||
replace_operand(lhs, replaces);
|
||||
replace_operand(rhs, replaces);
|
||||
}
|
||||
Instruction::UnaryOp { operand, .. } => {
|
||||
replace_operand(operand, replaces);
|
||||
}
|
||||
Instruction::UnaryOp { operand, .. } => replace_operand(operand, replaces),
|
||||
Instruction::Store { ptr, value } => {
|
||||
replace_operand(ptr, replaces);
|
||||
replace_operand(value, replaces);
|
||||
}
|
||||
Instruction::Load { ptr } => {
|
||||
replace_operand(ptr, replaces);
|
||||
}
|
||||
Instruction::Load { ptr } => replace_operand(ptr, replaces),
|
||||
Instruction::Call { callee, args, .. } => {
|
||||
replace_operand(callee, replaces);
|
||||
for arg in args.iter_mut() {
|
||||
replace_operand(arg, replaces);
|
||||
}
|
||||
}
|
||||
Instruction::TypeCast { value, .. } => {
|
||||
replace_operand(value, replaces);
|
||||
}
|
||||
Instruction::TypeCast { value, .. } => replace_operand(value, replaces),
|
||||
Instruction::GetElementPtr { ptr, offset, .. } => {
|
||||
replace_operand(ptr, replaces);
|
||||
replace_operand(offset, replaces);
|
||||
|
||||
Reference in New Issue
Block a user