Miscellaenous code cleanups.
This commit is contained in:
@@ -171,17 +171,15 @@ fn optimize_cpu_flags(
|
||||
|
||||
struct MemOpInfo {
|
||||
opcode: Opcode,
|
||||
inst: Inst,
|
||||
itype: Type,
|
||||
arg: Value,
|
||||
st_arg: Option<Value>,
|
||||
flags: MemFlags,
|
||||
offset: Offset32,
|
||||
add_args: Option<[Value; 2]>,
|
||||
}
|
||||
|
||||
fn optimize_complex_addresses(pos: &mut EncCursor, inst: Inst, isa: &TargetIsa) {
|
||||
let mut info = match pos.func.dfg[inst] {
|
||||
let info = match pos.func.dfg[inst] {
|
||||
InstructionData::Load {
|
||||
opcode,
|
||||
arg,
|
||||
@@ -189,13 +187,11 @@ fn optimize_complex_addresses(pos: &mut EncCursor, inst: Inst, isa: &TargetIsa)
|
||||
offset,
|
||||
} => MemOpInfo {
|
||||
opcode,
|
||||
inst,
|
||||
itype: pos.func.dfg.ctrl_typevar(inst),
|
||||
arg,
|
||||
st_arg: None,
|
||||
flags,
|
||||
offset,
|
||||
add_args: None,
|
||||
},
|
||||
InstructionData::Store {
|
||||
opcode,
|
||||
@@ -204,118 +200,113 @@ fn optimize_complex_addresses(pos: &mut EncCursor, inst: Inst, isa: &TargetIsa)
|
||||
offset,
|
||||
} => MemOpInfo {
|
||||
opcode,
|
||||
inst,
|
||||
itype: pos.func.dfg.ctrl_typevar(inst),
|
||||
arg: args[1],
|
||||
st_arg: Some(args[0]),
|
||||
flags,
|
||||
offset,
|
||||
add_args: None,
|
||||
},
|
||||
_ => return,
|
||||
};
|
||||
|
||||
if let ValueDef::Result(result_inst, _) = pos.func.dfg.value_def(info.arg) {
|
||||
let add_args = if let ValueDef::Result(result_inst, _) = pos.func.dfg.value_def(info.arg) {
|
||||
match pos.func.dfg[result_inst] {
|
||||
InstructionData::Binary { opcode, args } if opcode == Opcode::Iadd => {
|
||||
info.add_args = Some(args);
|
||||
}
|
||||
InstructionData::Binary {
|
||||
opcode: Opcode::Iadd,
|
||||
args,
|
||||
} => args,
|
||||
_ => return,
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
match info.opcode {
|
||||
Opcode::Load => {
|
||||
pos.func.dfg.replace(info.inst).load_complex(
|
||||
info.itype,
|
||||
info.flags,
|
||||
&info.add_args.unwrap(),
|
||||
info.offset,
|
||||
);
|
||||
pos.func
|
||||
.dfg
|
||||
.replace(inst)
|
||||
.load_complex(info.itype, info.flags, &add_args, info.offset);
|
||||
}
|
||||
Opcode::Uload8 => {
|
||||
pos.func.dfg.replace(info.inst).uload8_complex(
|
||||
pos.func.dfg.replace(inst).uload8_complex(
|
||||
info.itype,
|
||||
info.flags,
|
||||
&info.add_args.unwrap(),
|
||||
&add_args,
|
||||
info.offset,
|
||||
);
|
||||
}
|
||||
Opcode::Sload8 => {
|
||||
pos.func.dfg.replace(info.inst).sload8_complex(
|
||||
pos.func.dfg.replace(inst).sload8_complex(
|
||||
info.itype,
|
||||
info.flags,
|
||||
&info.add_args.unwrap(),
|
||||
&add_args,
|
||||
info.offset,
|
||||
);
|
||||
}
|
||||
Opcode::Uload16 => {
|
||||
pos.func.dfg.replace(info.inst).uload16_complex(
|
||||
pos.func.dfg.replace(inst).uload16_complex(
|
||||
info.itype,
|
||||
info.flags,
|
||||
&info.add_args.unwrap(),
|
||||
&add_args,
|
||||
info.offset,
|
||||
);
|
||||
}
|
||||
Opcode::Sload16 => {
|
||||
pos.func.dfg.replace(info.inst).sload16_complex(
|
||||
pos.func.dfg.replace(inst).sload16_complex(
|
||||
info.itype,
|
||||
info.flags,
|
||||
&info.add_args.unwrap(),
|
||||
&add_args,
|
||||
info.offset,
|
||||
);
|
||||
}
|
||||
Opcode::Uload32 => {
|
||||
pos.func.dfg.replace(info.inst).uload32_complex(
|
||||
info.flags,
|
||||
&info.add_args.unwrap(),
|
||||
info.offset,
|
||||
);
|
||||
pos.func
|
||||
.dfg
|
||||
.replace(inst)
|
||||
.uload32_complex(info.flags, &add_args, info.offset);
|
||||
}
|
||||
Opcode::Sload32 => {
|
||||
pos.func.dfg.replace(info.inst).sload32_complex(
|
||||
info.flags,
|
||||
&info.add_args.unwrap(),
|
||||
info.offset,
|
||||
);
|
||||
pos.func
|
||||
.dfg
|
||||
.replace(inst)
|
||||
.sload32_complex(info.flags, &add_args, info.offset);
|
||||
}
|
||||
Opcode::Store => {
|
||||
pos.func.dfg.replace(info.inst).store_complex(
|
||||
pos.func.dfg.replace(inst).store_complex(
|
||||
info.flags,
|
||||
info.st_arg.unwrap(),
|
||||
&info.add_args.unwrap(),
|
||||
&add_args,
|
||||
info.offset,
|
||||
);
|
||||
}
|
||||
Opcode::Istore8 => {
|
||||
pos.func.dfg.replace(info.inst).istore8_complex(
|
||||
pos.func.dfg.replace(inst).istore8_complex(
|
||||
info.flags,
|
||||
info.st_arg.unwrap(),
|
||||
&info.add_args.unwrap(),
|
||||
&add_args,
|
||||
info.offset,
|
||||
);
|
||||
}
|
||||
Opcode::Istore16 => {
|
||||
pos.func.dfg.replace(info.inst).istore16_complex(
|
||||
pos.func.dfg.replace(inst).istore16_complex(
|
||||
info.flags,
|
||||
info.st_arg.unwrap(),
|
||||
&info.add_args.unwrap(),
|
||||
&add_args,
|
||||
info.offset,
|
||||
);
|
||||
}
|
||||
Opcode::Istore32 => {
|
||||
pos.func.dfg.replace(info.inst).istore32_complex(
|
||||
pos.func.dfg.replace(inst).istore32_complex(
|
||||
info.flags,
|
||||
info.st_arg.unwrap(),
|
||||
&info.add_args.unwrap(),
|
||||
&add_args,
|
||||
info.offset,
|
||||
);
|
||||
}
|
||||
_ => return,
|
||||
}
|
||||
let ok = pos.func.update_encoding(info.inst, isa).is_ok();
|
||||
let ok = pos.func.update_encoding(inst, isa).is_ok();
|
||||
debug_assert!(ok);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user