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