Add comments and rename a local variable

This commit is contained in:
Olivier Goffart 2018-11-20 13:24:41 +01:00
parent 86d41350c7
commit 4c21f66c1d

View file

@ -243,7 +243,9 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
_ => bug!("OperandRef::extract_field({:?}): not applicable", self)
};
let bitcast = |bx: &mut Bx, val, ty| {
// HACK(eddyb) have to bitcast pointers until LLVM removes pointee types.
// Bools in union fields needs to be truncated.
let to_immediate_or_cast = |bx: &mut Bx, val, ty| {
if ty == bx.cx().type_i1() {
bx.trunc(val, ty)
} else {
@ -251,14 +253,15 @@ impl<'a, 'tcx: 'a, V: CodegenObject> OperandRef<'tcx, V> {
}
};
// HACK(eddyb) have to bitcast pointers until LLVM removes pointee types.
match val {
OperandValue::Immediate(ref mut llval) => {
*llval = bitcast(bx, *llval, bx.cx().immediate_backend_type(field));
*llval = to_immediate_or_cast(bx, *llval, bx.cx().immediate_backend_type(field));
}
OperandValue::Pair(ref mut a, ref mut b) => {
*a = bitcast(bx, *a, bx.cx().scalar_pair_element_backend_type(field, 0, true));
*b = bitcast(bx, *b, bx.cx().scalar_pair_element_backend_type(field, 1, true));
*a = to_immediate_or_cast(bx, *a, bx.cx()
.scalar_pair_element_backend_type(field, 0, true));
*b = to_immediate_or_cast(bx, *b, bx.cx()
.scalar_pair_element_backend_type(field, 1, true));
}
OperandValue::Ref(..) => bug!()
}